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)

  • "Intentionally a duplicate" will be promptly closed as a duplicate - nobody will be able to find it. When you have enough reputation, then add your answer to that question. – user535733 Oct 18 '18 at 17:22
  • How weird - a post motivated by the forum being dysfunctional immediately receives two comments illustrating exactly that. Is no one here interested in getting correct answers? Allow me to point out again - the post marked as a possible duplicate is in error, and exactly the reason why I posted this duplicate question. Who cleans out low-quality answers like that? "sudo crontab -e" does NOT edit /etc/crontab – Johan E. Bengtsson Oct 18 '18 at 19:21
  • There are two things you could do to improve the quality of answers to a question without having any reputation: 1) Post your own, better answer. 2) Suggest (an) edit(s) to any of the answers to make small corrections, fix formatting, add details, etc. If you reach 5 reputation points (suggest 2 edits that are approved), you can also post on meta asking for help improving the Q&A. I'm voting to close this question because it's unclear what you're asking. If you edited it to be more meta, I would vote to migrate to meta. If you removed the meta content, I would vote to close it as a duplicate. – Zanna Oct 18 '18 at 19:45
  • Thanks for trying to give advice, but - how do these referrals to previous duplicate questions with incorrect answers get a fix then? I CANNOT add anything to those questions (neither the latest question nor the previous duplicates), since reputation appears to be needed. I tried to provide a quality answer to the relevant question here. – Johan E. Bengtsson Oct 18 '18 at 20:38
  • Oh I see, my bad, sorry! The question is protected. I've just unprotected it so you can add your answer there. It has had a lot of spam and non-answer answers posted on it, so it'll need to be protected again after you've done so (you can notify me by including @Zanna in a comment here, but other users could also protect the question) The one you linked to in your question is closed as a duplicate so cannot be answered, but the answers can be edited. – Zanna Oct 18 '18 at 21:32
  • Meanwhile I commented on Yaron's answer to suggest it's misleading at present – Zanna Oct 18 '18 at 21:44
  • @Zanna, I proposed an answer edit at https://askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job/2371#2371, mentioning also the /etc/cron.d/ folder which is a lot better than some other suggestions to try to make automatic edits to /etc/crontab or /var/spool/cron/crontabs/root . – Johan E. Bengtsson Oct 18 '18 at 22:10
  • Thanks a lot for trying to do that. Unfortunately reviewers rejected your suggestion, despite its correctness and the good edit summary you provided. I've edited the post myself. Is that better? Do feel free to suggest a further edit, but I can't guarantee it will be approved :( Perhaps rather than the section you proposed adding to the end of the answer being edited in, a new answer could be added with that advice. Would you like to add one? – Zanna Oct 19 '18 at 08:13

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