$ sudo cat /etc/crontab
# ...comment lines elided...
0 0,12 * * * root sleep 1347 && certbot renew -q --post-hook 'sudo reboot'
sudo crontab -e
shows
13 0,12 * * * root sleep 1347 && certbot renew -q
This VM is a simple default-configured Google Compute Engine VM with Debian Buster. I am logged in as a user joshua, but note that sudo does not require entering a password.
Which one (or perhaps both?) shows what cron actually does? What is the recommended way to edit the cron config, crontab -e
or directly editing some file, e.g. with sudo vi
?
sudo crontab -e
? There shouldn't be auser
field in that file. It looks like both lines you show are actually from/etc/crontab
. What do you mean by "what cron actually does"? Cron will run everything it is told to run. And no,sudo crontab -e
will show root's user-crontab, not yours. – terdon Feb 10 '22 at 11:35sudo crontab -e
is wrong, only/etc/crontab
should have a user as the 6th field, so the line should be13 0,12 * * * sleep 1347 && certbot renew -q
. – terdon Feb 10 '22 at 11:57crontab -e
verifies your edits, refuses to install a crontab with errors, and signals the cron daemon that it should refresh its internal copy of the new file.vi crontab
does none of those things, and is inviting disaster. Also,crontab -l
will list your crontab file. Hint: crontab default editor isnano
on my box --EDITOR=vi crontab -e
is my friend here. – Paul_Pedant Feb 10 '22 at 14:35/etc/crontab
– Joshua Fox Feb 10 '22 at 15:09