linux - Difference between /etc/crontab and "crontab -e"

05
2014-04
  • jrdioko

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

  • Answers
  • skrewler

    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 Linux distros, per user crontabs are typically stored in: /var/spool/crontabs/<username>

  • Ignacio Vazquez-Abrams

    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.


  • Related Question

    bash - user crontabs don't work, only /etc/crontab
  • gletscher

    Hi when I use the command

    crontab -e
    

    to set up cron, the commands get triggered (according to syslog) but nothing happens. Also if I run sudo crontab -e.

    The only way to actually get cron working is to manually etc

    /etc/crontab
    

    I'm confused, since syslog gives me the same output for both methods. Any ideas for tracing down this bug? Thanks a lot!


  • Related Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.