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?

  • Can I save the crontab file under $HOME? Why do I need a symlink?
    – Tim
    Commented Apr 20, 2015 at 23:43

3 Answers 3


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.

  • where is my crontab file stored eventually? If I log out of the server, what will happen to my crontab file? (I am not a admin, and doesn't not have root access to the server)
    – Tim
    Commented Apr 20, 2015 at 23:45
  • 1
    your actual crontab lives somewhere in /var/spool (typically), but you should never touch your actual crontab and you should never need to, either - use crontab -e instead. You probably don't have the right access level to edit the raw crontab file anyway.
    – jayhendren
    Commented Apr 20, 2015 at 23:46
  • if you log out, nothing will happen to your crontab. it doesn't live in /tmp.
    – jayhendren
    Commented Apr 20, 2015 at 23:47
  • (1) Is crontab file for individual user or for all users? (2) How can I verify if my edit to crontab file works?
    – Tim
    Commented Apr 20, 2015 at 23:48
  • crontabs are per user. to verify that your cronjob runs, you can check the cron logs. typically in /var/log/cron.log, but it could be other locations as well.
    – jayhendren
    Commented Apr 20, 2015 at 23:49

/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.


Crontab files reside in /var/spool/cron/crontabs/ under one's username or user ID. Since situations can arise where the crontab located here is no longer connected to your login account, it is recommended that you save a copy to your home directory, say /home/userid/.crontab, so that you can easily restore it should you need to. This also permits you to place it under revision control should you like.

If you're home directory is relocated to another system, often the crontab from the spool directory doesn't accompany it unless your system admin takes this into account. Nor is /var/spool always backed up or restored when a system needs to be redone.

So again it is recommended that a copy of your crontab be kept under your home directory.

Use your favorite editor (pico, vi, emacs, etc) to edit ~/.crontab and then use crontab to apply it to /var/spool/crontabs. Like this:

% pico ~/.crontab; crontab ~/.crontab

If you like aliases, you can make one to run instead.

  • 1
    Do I have to do something to make my home's crontab file override crontab files in other location?
    – Tim
    Commented Apr 21, 2015 at 0:14
  • Just run "crontab ~/.crontab" and you'll apply it to the one in /var/spool/cron/crontabs. Use pico, emacs, or vi to edit ~/.crontab before hand to make any changes.
    – JonathanS
    Commented Apr 21, 2015 at 0:45
  • This does not actually answer the question.
    – nobody
    Commented Apr 21, 2015 at 2:19
  • @AndrewMedico: The primary question seemed to be "Where shall I store my crontab file? Can I save the crontab file under $HOME or some better space?" Or are you referring to Tim's question in the comment here?
    – JonathanS
    Commented Apr 21, 2015 at 4:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .