Difference Between /Etc/Crontab and "Crontab -E"

Difference Between /Etc/Crontab and "Crontab -E"

What is the difference between the crontab located in /etc/crontab and the crontab that can be edited using crontab -e?

2 Answers

As Ignacio said, /etc/crontab is the system wide crontab.

The format of /etc/crontab is like this:

# m h dom mon dow user      command
*   *  *   *   *  someuser  echo 'foo'

while crontab -e is per user, it's worth mentioning with no -u argument the crontab command goes to the current users crontab. You can do crontab -e -u <username> to edit a specific users crontab.

Notice in a per user crontab there is no 'user' field.

# m h  dom mon dow  command
*   *   *   *   *   echo 'foo'

An aspect of crontabs that may be confusing is that root also has its own crontab. e.g. crontab -e -u root will not edit /etc/crontab See Configuring cron.

In most Linux distros, per user crontabs are typically stored in: /var/spool/cron/crontabs/<username> (vixie-cron).

RHEL based distributions are stored in /var/spool/cron/<username>. (cronie)

5

One is the system crontab and can only be edited by root, and the other is the user crontab and can be edited by a user and exists per user.

Your Answer

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

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.