Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

What is the difference between crontab -e and nano /etc/crontab? [duplicate]

Writer Andrew Henderson

What is the difference between crontab -e and nano /etc/crontab? Do they point to the same thing?

1

2 Answers

The crontab -e command will edit the crontab for your current user. This means that you do not need to include the username in the crontab line. Each user's crontab is stored in /var/spool/cron/crontabs, under the user's name.

The format of a user specific crontab is:

# m h dom mon dow command
* * * * * some_command

The crontab -e command will use whichever editor is set in your user's $EDITOR environment variable, which controls your default text editor for a variety of tasks. If that isn't set the first time you use the crontab command you'll be prompted to choose from a selection of available editors, nano is one of the choices on this list.

Editing /etc/crontab requires that you include a username that's running the command after the time setting part of the line.

The format of /etc/crontab is:

# m h dom mon dow user command
* * * * * someuser some_command
8

The traditional system cron list is at /etc/crontab

The user crontabs are usually located at /var/spool/cron/crontabs/$USER.

Doing a 'crontab -e' automatically invokes the users editor and performs a basic validity/syntax check when you attempt to exit.

Any jobs scheduled using the user crontab are run under the users login id whereas the the system /etc/crontab has the capability to schedule jobs under any system userid listed in /etc/passwd.

If you want to play with fire, you can directly edit (vi/vim/nano/mcedit/...) your user crontab, bypassing any syntax check, by using for instance, "nano /var/spool/cron/crontabs/your-login-id" [ Or any userid if you are root or use sudo ]

For more detailed info, you might want to peruse the cron man pages ( 'man cron' )