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?

30 2 * * 1 /usr/bin/letsencrypt renew >> /var/log/le-renew.log
0 4 * * * root /sbin/reboot

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/reboot

to 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 -e

to edit root's crontab – not yours. Drop the user specification, i.e. add the following line:

0 4 * * * /sbin/reboot

But 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.