Cron Tmp – Should Crontab File Be Saved in /tmp?

crontmp

I ssh to a server, and want to add some daily jobs (specifially to renew Kerberos tickets even when I log out and I still want my programs in screen or tmux continue to run) to cron. So I run crontab -e, and add the following,

00 00 * * * kinit -R
00 12 * * * kinit -R

When I save it, I am asked by the editor:

File Name to Write: /tmp/crontab.HMpG7V 

Isn't it that the files in /tmp can be deleted by the OS? Especially after I log out of the server?

Where shall I store my crontab file? Can I save the crontab file under $HOME or some better space?

Best Answer

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.

Related Question