如何限制Crontab文本输出。

时间:2018-07-31 19:52:42

标签: cron syslog

cron运行时,它从运行的脚本中输出文本,然后 系统调用。有没有办法限制输出?

从此:

From x.site  Tue Jul 31 13:32:45 2018
Return-Path: <a.site>
X-Original-To: a
Delivered-To: a.site
Received: by x.site (Postfix, from userid 1000)
    id 1458910057D; Tue, 31 Jul 2018 13:32:45 -0400 (EDT)
From: "(Cron Daemon)" <a.site>
To: a.site
Subject: Cron <>
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=3737>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/1000>
X-Cron-Env: <DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus>
X-Cron-Env: <LC_CTYPE=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/ab10>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=a>
X-Cron-Env: <USER=a>
Message-Id: <20180731173245.1458910057D@BMCap3.site>
Date: Tue, 31 Jul 2018 13:30:04 -0400 (EDT)


Text from script..

对于这样的事情:

From x.site  Tue Jul 31 13:32:45 2018
Return-Path: <a.site>
Subject: Cron <>
Content-Type: text/plain; charset=UTF-8
Date: Tue, 31 Jul 2018 13:30:04 -0400 (EDT)


Text from script..

2 个答案:

答案 0 :(得分:1)

作为命令的一部分,将输出重定向到dev null

所以您要运行的cron命令应该是> / dev / null

要过滤某些内容,可以使用管道“ blah | awk或grep”

答案 1 :(得分:0)

这是bash脚本...

span