Every hour I get an email with error like this,
Subject: Cron <root@supa> root cd / && run-parts --report /etc/cron.hourly
/bin/sh: root: not found
Contents of /etc/crontab is as follows, either I remove user "root" or not (6th column), I get the same error.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
11 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
There are two files in my cron.hourly directory,
$ ll /etc/cron.hourly/
total 0
lrwxrwxrwx 1 root root 25 2009-10-29 09:24 ntpsync -> /home/<user>/bin/ntpsync
lrwxrwxrwx 1 root root 28 2009-10-23 10:33 foo -> /home/<user>/bin/foo
First script reads as follows,
$ cat ~/bin/ntpsync
#!/usr/bin/env bash
echo "user: $USER"
if [[ "$USER" == "root" ]] ; then
ntpdate ntp.ubuntu.com
else
sudo ntpdate ntp.ubuntu.com
fi
Even I remove both scripts in my /etc/cron.hourly/ directory, I still get the same error email every hour. I tried to restart cron and I still get the same error email. The next idea I have is to reboot but I'd avoid that.
$ sudo /etc/init.d/cron restart
My Ubuntu version is as follows,
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.1"
Update: I removed the 6th columns "root" from my /etc/crontab file earlier because when I searched online someone mentioned that could fix the problem. Now I think the problem was that I was messing around with the system crontab config instead of that of the root's.
$ sudo crontab -l
# m h dom mon dow command
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 )