I've noticed that crontab -e and sudo crontab -e seem to edit separate files. How do these two commands differ, and in what circumstances should each be used?

  • 1
    Arguably user neither but as an admin drop a file in /etc/crond.d or in the relevant /etc/cron.[hourly |daily |weekly |monthly] directory
    – HBruijn
    Nov 28, 2016 at 21:32

2 Answers 2


crontab -e edits the crontab for the current user, so any commands contained within will be ran as the user who's crontab you are editing. sudo crontab -e will edit the root users crontab, and so the commands within will be run as root.


To add on to cduffin, use the minimum permissions rule when running your cronjob. If the job can effectively be run as a regular user, have the job run as them. If the cronjob requires escalated privileges, add the job as the root user.

To be super security conscious, you can figure out what root level commands need run and set the regular user up in the /etc/sudoers file to be allowed to run that single command... Example:

Defaults:johndoe !requiretty
johndoe ALL=NOPASSWD:/usr/bin/tail /var/log/yum.log*

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .