我有这个奇怪的邮件来自cron:
Return-Path: <[email protected]> Delivered-To: [email protected] Received: by domain.com (Postfix, from userid 0) id 6F944264D0; Mon, 10 Jan 2011 10:35:01 +0000 (UTC) From: [email protected] (Cron Daemon) To: [email protected] Subject: Cron <root@domain> lynx -dump http://www.domain.com/cron/realqueue Content-Type: text/plain; charset=ANSI_X3.4-1968 X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin> X-Cron-Env: <HOME=/root> X-Cron-Env: <LOGNAME=root> Message-Id: <[email protected]> Date: Mon, 10 Jan 2011 10:35:01 +0000 (UTC) /bin/sh: lynx: not found
我在crontab文件中有这个cron设置:
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin */5 * * * * lynx -dump http://www.domain.com/cron/realqueue 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
Lynx也安装在我的Ubuntu上。
Ofc代替domain.com是我的域名,只是取而代之。
谢谢 ;)
您应该检查以确保lynx二进制文件位于PATHvariables中指定的位置之一,或使用cron行中的二进制文件的完整path。 为了抑制错误,你需要将STDERR和STDOUTredirect到/ dev / null,如下所示:
*/5 * * * * lynx -dump http://www.domain.com/cron/realqueue >/dev/null 2>&1
第一次redirect将STDOUT发送到/ dev / null,第二次发送STDEROUT和STDOUT(即到/ dev / null)。
真正的问题是这样的:
/ bin / sh:lynx:找不到
这是说,l is没有find,所以你的crontab行甚至没有运行。 使用来自Scrivener或blueben的redirectbuild议来抑制错误,你只是隐藏了一个事实,即你想要实际运行的命令没有被运行。
一般来说,cron会发送这些邮件来寻找错误信息。 抑制电子邮件的最好方法是修复错误,并且只有当您无法修复错误(例如,脚本始终嘈杂)时,才会开始将输出redirect到/ dev / null。
将MAILTO添加到您的crontab的顶部,并将其设置为空string:
MAILTO=""
你要:
* / 5 * * * * lynx -dump http://www.domain.com/cron/realqueue >> / dev / null 2>&1
如果你想要lynx二进制文件的path,最简单的命令是which lynx 。
这应该给你一些像/usr/bin/lynx
也许l bin的二进制文件没有在$ PATH中注册。
在你的shell中试试这个:
# locate lynx
它会返回一些string。 select一个导致l bin的二进制文件,然后做
# export PATH=$PATH:{the firstly returned string path until last dir}