cronjob says "/bin/sh: 1: root: not found"
My cronjob command are below and I get this email daily. I'm trying to reboot server (ubuntu 18.04) every night. What is the issue here?
MAILTO=""
30 2 * * 1 /usr/bin/letsencrypt renew >> /var/log/le-renew.log
0 4 * * * root /sbin/reboot 0 1 Answer
Cronjobs created via crontab -e are run as the user who
issues that command and thus owns that cronjob. You cannot
supply a user in the line
0 4 * * * root /sbin/rebootto have that job run as root. If that was the case, one
could run arbitrary commands as another user. Nobody would
want that.
When you want to run a cronjob as user root you must issue
sudo crontab -eto edit root's crontab – not yours. Drop the user specification,
i.e. add the following line:
0 4 * * * /sbin/rebootBut there is also the possibility to define cronjobs in
files below /etc/cron.d. In that case the syntax is a bit different
and the first column after the time specification must contain the
user as whom the job is to be run. But that syntax is only applicable
to files below /etc/cron.d.