2

This is intentionally a duplicate of the following question (because the answers there are not completely correct, and as a new user I somehow cannot comment there): Editing crontab

ADDED NOTE: The "How do I set up a Cron job?" question too wrongly states that "sudo crontab -e" edits /etc/crontab (it does NOT) - it IS marked as a duplicate of the "Editing crontab" question.

(hoping to get some upvotes here, so I can help correcting wrong answers in the intended way)

1 Answers1

3

Per-user CRON jobs are best handled with the crontab command, crontab -l for showing your own CRON jobs, crontab -e for editing (some syntax errors will be detected), and crontab -r for removing all your CRON jobs (don't do that...). sudo crontab does the same, for the root user.

Duplicate questions have accepted answers that wrongly claim that sudo crontab -e edits /etc/crontab. It does NOT, it edits /var/spool/cron/crontabs/root. I have verified this in Ubuntu 14.04 and Ubuntu 18.04.

/etc/crontab is a system-wide file that can run jobs as any user, typically stored as fragments in /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly and /etc/cron.monthly. For precise control of timing and user, add fragments in /etc/cron.d/ .