Pages

How cronjobs are handled when the time on a server changes

Cronjobs are handled according to the amount of time "missed" by cron. By checking a timer specific to cron against the currently reported system time, cron breaks "missed" time into one of 4 scenario

  • If the difference in time is greater than 1 minute, but less than 5 minutes, crond increments its internal timer by one minute every 10 seconds until its time is caught up with the system's time, running all scheduled jobs for each of these "virtual" 10 second minutes.

  • If the difference in time is greater than 5 minutes, but less than 3 hours, crond first runs any "wildcard" jobs (scheduled for every X minutes or hours) for the current system time, and then begins running missed "fixed-time" jobs as above, starting those jobs for cron's current "virtual" minute, sleeping for 10 seconds, and then starting jobs for the next "virtual" minute.

  • If the difference in time is greater than +/-3 hours, crond simply adjusts its internal time to the current system time and runs any current jobs. Jobs that would have fallen in the intervening time are skipped.

  • If the difference in time is a negative time jump, i.e. difference in time is between 0 and -3 hours, crond runs any "wildcard" jobs (scheduled for every X minutes or hours) for the current system time and ignores any "fixed-time" or missed "wildcard" jobs. crond does not update its internal time in this scenario, instead waiting for the system's time to catch up.


No comments:

Post a Comment