jojo_angelov
Posts: 38
Joined: Mon Jan 06, 2014 1:59 am

Will a cronjob execute imemdiately if device was off

Sat Jan 31, 2015 6:09 am

So say I have a cron job running every day at 8 AM. If my pi was off, say from 7AM to 3PM, and then I turn my pi on, will the cronjob execute immediately or would it not execute at all since it missed its slot?

User avatar
rpdom
Posts: 15580
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Will a cronjob execute imemdiately if device was off

Sat Jan 31, 2015 6:22 am

It would not execute at all because of the missed slot.

However, if you replace cron with anacron (sudo apt-get install anacron), that will run cron jobs that would have been missed if the system wasn't running at the time. Other than that, anacron is exactly the same as cron - uses the same files and commands.
Anacron (like "anac(h)ronistic") is a periodic command scheduler. It executes commands at intervals specified in days. Unlike cron, it does not assume that the system is running continuously. It can therefore be used to control the execution of daily, weekly, and monthly jobs (or anything with a period of n days), on systems that don't run 24 hours a day. When installed and configured properly,
Anacron will make sure that the commands are run at the specified intervals as closely as machine uptime permits.

Return to “General discussion”