I'm attempting to run a cron job as root user, but it will not execute. Here's what I've tried...
Adding the job to my user crontab (crontab -e) and setting the user as root...
17 10 * * * root /etc/cron.daily/cammedia.sh
Adding the job to the root user crontab (sudo crontab -e) and also adding the a few PATH's...
PATH=/usr/sbin:/usr/bin:/sbin:/bin PATH=/usr/sbin:/usr/bin:/sbin:/etc PATH=/bin:/sbin:/usr/bin:/usr/sbin:/home/scott PATH=/bin:/sbin:/usr/bin:/usr/sbin:/etc # 0 4 * * * /etc/cron.daily/cammedia.sh
Here's the result of running crontab -l (local user account) after a test run:
May 26 10:17:01 WEBCAM CRON[89901]: (scott) CMD (root /etc/cron.daily/cammedia.sh)
May 26 10:17:01 WEBCAM CRON[89902]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
May 26 10:17:01 WEBCAM CRON[89900]: (CRON) info (No MTA installed, discarding output)
Suggestions?
crontab -e
orsudo crontab -e
in the case ofroot
) do not support an additional field to specify the user - that's only valid in the system-wide crontab file/etc/crontab
. Seeman 5 crontab
for discussion of the differences.cammedia.sh
to be executed.grive
from/etc/cron.hourly
?