Shall I save my crontab file in /tmp?

crontab -e opens a file in /tmp instead of the actual crontab so that it can check your new crontab for errors and prevent you from overwriting your actual crontab with those errors. If there are no errors, then your actual crontab will be updated. If crontab -e just wrote straight to your actual crontab, then you would risk all of your cronjobs failing to run due to a syntax error in your new crontab.

sudoedit, visudo, vipw, etc. operate on the same principle.

Don't worry, your actual crontab lives in a non-volatile location on disk.


/tmp is where the temporary crontab file is written to. After you save and quit, crontab will commit the changes to a different, more appropriate directory on your system (usually at /var/spool/cron, if I remember right). So, don't worry, the operating system may delete your /tmp, but it will never take away your crontabs.

Tags:

Cron

Tmp