1

Seems like such a simple question, but I can't find an answer to:

Cron is scheduled to run daily, say at midnight. If my system is offline during that period of time and I turn it on the next day, cron won't run my jobs on boot. Is there any way to change this behaviour, say by making all backlogged jobs run at once on boot?

4 Answers 4

7

Not with vixiecron, not exactly.

You probably want anacron, which was specifically created to cover the "offline" gap in cron. Anacron is designed to work with cron, but you could use a complete cron replacement instead. FCron is one which will take system down time in to account.

2
  • Thanks, I'm currently using dcron, but this is probably what I need.
    – david
    Sep 29, 2010 at 16:24
  • This is the right way to do it. Sep 29, 2010 at 22:47
1

You might need to add a separate entry:

@reboot /path/to/job

2
  • Is it possible to run once on reboot, but only a maximum of once a day? Thanks
    – david
    Sep 29, 2010 at 16:09
  • I suggest you do a verification on the script that will check if the script has already been executed for the day. For this, all I can think of is using the date command and check it against a file wherein another date is written. It will be the same file which the script will overwrite the current value if date is not the same (after execution)
    – Ruel
    Sep 29, 2010 at 16:17
1

I'd say that in a robust system, run the cron jobs more often than you really want, and have them check if they need to do any work, and only do it if necessary.

THis is often a good idea anyway, as a previous run may have failed.

0

I suppose you need this. Apparently, you can schedule jobs to run only once a day using /etc/cron.daily.

You must log in to answer this question.