Cron – How to stop Cron from sending messages about errors

cron

I have this strange mails comming from cron:

Return-Path: <root@domain.com>
Delivered-To: root@domain.com
Received: by domain.com (Postfix, from userid 0)
    id 6F944264D0; Mon, 10 Jan 2011 10:35:01 +0000 (UTC)
From: root@domain.com (Cron Daemon)
To: root@domain.com
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: <20110110103501.6F944264D0@domain.com>
Date: Mon, 10 Jan 2011 10:35:01 +0000 (UTC)

/bin/sh: lynx: not found

I have this cron settings in crontab file:

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 is installed on my Ubuntu as well.

Ofc in place of domain.com is my domain, just replaced.

Thanks 😉

Best Answer

You should check to make sure the lynx binary is in one of the locations specified in the PATH variable, or use the full path to the binary in the cron line. To surpress the errors, you want to redirect STDERR and STDOUT to /dev/null, like so:

*/5 * * * * lynx -dump http://www.domain.com/cron/realqueue >/dev/null 2>&1

The first redirection sends STDOUT to /dev/null, and the second sends STDERR with STDOUT (that is, to /dev/null).

Related Topic