1

I have set up cron jobs using the following command

crontab -e

It seems that if a cron job is scheduled to run within the same day (i.e. computer has not been rebooted), then the cron job runs OK. However, if a cron job is scheduled to run several days later (i.e. computer has been rebooted at least once), then the cron job would be missed.

Moreover, every time when I use "crontab -e" to edit the crontab file in the "nano" editor, the top line shows that I am editing a different file, e.g.

File : /tmp/crontab.PLwi9Z/crontab
File : /tmp/crontab.degfpN/crontab
File : /tmp/crontab.odqbkT/crontab

I want to know that is this normal for crontab and how to schedule a job to run several days later (i.e. after several reboots). I am using an Ubuntu 12.04 amd64 system.

Thanks for any suggestion.

  • Have you checked your cron log to see if there are any errors? Also, make sure that crond is running and not crashing – Machavity Dec 4 '16 at 2:14
  • I have just added an entry 30 10 4 12 * my_command in the crontab file to send out a sound and it works. It indicates that the "cron" daemon should be running correctly and my_command should be working OK. I have now modify the entry to 30 10 5 12 * my_command to see whether my computer would similarly send out a sound tomorrow at 10:30am. I would not edit the crontab file any more and would shut down my computer tonight. From my experience, the cron job tomorrow would be missed after I reboot my computer tomorrow morning. – user1129812 Dec 4 '16 at 3:11
  • I wonder that is it normal for "cron" to forget its entry after reboot, or I have made some other mistakes. – user1129812 Dec 4 '16 at 3:14
  • Moreover, there is only ONE entry in my crontab file, so this entry should not be interfered by other entries. – user1129812 Dec 4 '16 at 3:25
  • Oh, my crontab entry works OK this time. My computer gives a sound today at 10:30am. However, I have previous experience that a crontab entry did not work. Perhaps previously my edited crontab entry had not been installed properly as I have tried not to use "nano" to edit crontab entry, but I could not reproduce the mistake now. Anyway, thanks for anyone who pays attention to this question. – user1129812 Dec 5 '16 at 2:44
5

Moreover, every time when I use "crontab -e" to edit the crontab file in the "nano" editor, the top line shows that I am editing a different file, e.g

The crontab -e command is 'smart', it makes a temporary copy of the file for you to edit. When you save the file it checks that the file is (reasonably) correct before installing it into the correct location on your system.

I want to know that is this normal for crontab and how to schedule a job to run several days later

If your system is turned off when a crontab entry should run then it will be missed. This is normal. If you have jobs that should run even when they have been missed by the system being powered off then take a look at anacron.

  • Thanks for the "anacron" suggestion. It seems a good tool. – user1129812 Dec 5 '16 at 2:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.