Ubuntu – Crontab -e opens new file each time I run it

cronPHP

Cronjob was working for couple of months, until something mysteriously happened and then it stopped. I checked under the user and under the root, and couldnt find any cronjobs. However what I am really interested in, when I first started cronjob with sudo crontab -e, file that was opened had lots of comments in it. Also each time I would hit that command, same file with all cronjobs would be opened for me. Now when I run it each time I get open different blank file:

/tmp/crontab.Tpv8X6/crontab
/tmp/crontab.fckvR2/crontab 
etc. 

Why is this happening? I would like to be able to open same file all over again.

Best Answer

These are temporary files created whilst crontab -e is invoked (i.e. while your editor is still open). Actual user crontabs are kept in:

/var/spool/cron/crontabs

So you can check there for crontabs you expect to exist. However these files are not supposed to be edited directly, you should continue to use crontab -e to edit/update your cron jobs. Alternatively you can edit the global crontab at:

/etc/crontab

which has an extra 'user' field for you to specify the user under which the command should be run.

Related Question