Answers.Body: <p>I don't know if this is the case here, and it seems more regular than my experience, but my coworkers and I have seen cron jobs walk fairly regularly.  (We're more commonly using Ubuntu 14.04 or 12.04, however.)</p>
  
  <p>The usual issue I see is the following with a daily scheduled job:</p>
  
  <ul>
  <li>cron run starts at 1:00:00</li>
  <li>there are a bunch of things to do, so it gets to the daily job at 1:00:20</li>
  <li>the next day at 1:00:00, cron runs again</li>
  <li>there's less to do, so it gets to the daily scheduled job at 1:00:10</li>
  <li>being "daily", the scheduled job checks to make sure its previous run was more than one day ago, and that check fails since it was 23 hours, 59 minutes, 50 seconds ago</li>
  <li>the scheduled job executes the next time cron runs</li>
  </ul>
  
  <p>In my experience, that would normally make the scheduled job walk one cron interval (usually 5, 6, 10, or 15 minutes) rather than an entire hour.  However, if you only have the cron job running hourly, that would explain your phenomenon exactly.</p>
  
  <p>Unfortunately, there's no way to guarantee that a scheduled job will get run at a precise time each day unless you have a separate cron job to run the single scheduled job.  However, reducing the cron interval will mean that when the schedule job does walk, it'll take smaller steps.</p>
  
  <p><em>(Side note: this situation is why I always have the scheduled reminders job run hourly rather than daily.  Otherwise, the scheduled job might walk all the way to 11:00 pm, potentially reminding people about the next day's event after the recipients have gone to bed.)</em></p>
  
  <p><strong>UPDATE:</strong> As Karin describes below, this was addressed in 4.6.3, so the later 4.6.x releases all fix this.  However, some changes introduced in 4.7 had the result of undoing this.  The relevant issue is <a href="https://issues.civicrm.org/jira/browse/CRM-18671" rel="nofollow">CRM-18671</a> for describing what's going on.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-24T19:22:37.927Z
Answers.Text: Thanks Andrew! I'm hesitant to move this recurring contributions job from daily to hourly - though I understand that would in all likelihood reduce the speed at which these jobs are walking.
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-24T19:24:39.837Z
Answers.Text: So your update explains why this is all working for us on the hours - exactly - for all our 4.6.x-es. Thanks for creating the JIRA issue: https://issues.civicrm.org/jira/browse/CRM-18671
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-06T18:25:12.687Z
Answers.Text: Worth noting, the CronPlus extension (https://lab.civicrm.org/extensions/cronplus) purports to alleviate this problem.
Answers.UserDisplayName: TwoMice
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-24T18:14:59.527Z
Answers.LastActivityDate: 2016-05-24T19:11:15.083Z
Answers.LastEditDate: 2016-05-24T19:11:15.083Z
Answers.UserDisplayName: Andie Hunt
Answers.Body: <p>This extension might solve this issue: <a href="https://lab.civicrm.org/extensions/cronplus" rel="nofollow noreferrer">Cron Plus</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-18T14:30:45.177Z
Answers.LastActivityDate: 2020-11-18T14:30:45.177Z
Answers.UserDisplayName: luciano_s
Answers.Body: <p>This may actually not be related to Centos7 vs Centos6 but due to the fact that the project in question is still on 4.4 LTS - Looks like this was addressed in 4.6.3: <a href="https://issues.civicrm.org/jira/browse/CRM-16276" rel="nofollow">https://issues.civicrm.org/jira/browse/CRM-16276</a> - thanks @Allan Shaw!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-24T18:23:41.937Z
Answers.Text: Ooh, I didn't know about this fix.  It's for 4.6 only, however--that trick of looking at the hour or day is no longer in effect for 4.7: https://github.com/civicrm/civicrm-core/blob/1e7702fee94c891c1c1b3ec4d43688991f96b6af/CRM/Core/ScheduledJob.php#L154
Answers.UserDisplayName: Andie Hunt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-24T19:10:29.927Z
Answers.Text: I do recall seeing this a few years ago but not going down the rabbit hole to diagnose, etc.
Answers.UserDisplayName: Joe Murray
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-24T19:18:50.483Z
Answers.Text: @AndrewHunt - shoot I thought I was onto something! :-)
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-24T18:09:21.967Z
Answers.LastActivityDate: 2016-05-24T18:09:21.967Z
Answers.UserDisplayName: KarinG - Semper IT
Body: <p>We're only seeing this for projects on one specific server (running Centos7; using chrony; PHP 5.6.21). We are NOT seeing this for projects on our other server (running Centos6; using ntpd); Working theory is that we should go to ntpd on Centos7. Has anyone else run into this? </p>
  
  <p><strong>The problem:</strong> a Scheduled Job configured to run daily - runs <strong>exactly every 25h:</strong></p>
  
  <pre><code>2016-05-21 15:04:51 
  2016-05-20 14:04:17 
  2016-05-19 13:04:41
  </code></pre>
  
  <p><strong>EDIT:</strong> system crons (Drupal and CiviCRM) run hourly - on 03 and 04, respectively - and I've confirmed those jobs that are scheduled to run 'always' indeed execute every hour.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-08T17:39:23.043Z
Comments.Text: FYI, this was fixed in core 4.6.3, but regressed some time ago (as early as 4.7.7 per https://issues.civicrm.org/jira/browse/CRM-18671). The current (and fairly dormant) ticket is here: https://lab.civicrm.org/dev/core/-/issues/1799
Comments.UserDisplayName: TwoMice
Tags: <cron-job><cron><webserver>
Title: Has anyone run into scheduled jobs drifting on Centos7?
ThreadText: # Has anyone run into scheduled jobs drifting on Centos7?
  
  (Asked by: username_0 on 2016-05-24)
  
  We're only seeing this for projects on one specific server (running Centos7; using chrony; PHP 5.6.21). We are NOT seeing this for projects on our other server (running Centos6; using ntpd); Working theory is that we should go to ntpd on Centos7. Has anyone else run into this?
  
  **The problem:** a Scheduled Job configured to run daily - runs **exactly every 25h:**
  
  ```
  2016-05-21 15:04:51 
  2016-05-20 14:04:17 
  2016-05-19 13:04:41
  
  ```
  
  **EDIT:** system crons (Drupal and CiviCRM) run hourly - on 03 and 04, respectively - and I've confirmed those jobs that are scheduled to run 'always' indeed execute every hour.
  
  **Tags:** cron-job, cron, webserver
  
  > **Comments:**
  > **username_1**: FYI, this was fixed in core 4.6.3, but regressed some time ago (as early as 4.7.7 per https://issues.civicrm.org/jira/browse/CRM-18671). The current (and fairly dormant) ticket is here: https://lab.civicrm.org/dev/core/-/issues/1799  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2016-05-24. Score: 3
  
  I don't know if this is the case here, and it seems more regular than my experience, but my coworkers and I have seen cron jobs walk fairly regularly. (We're more commonly using Ubuntu 14.04 or 12.04, however.)
  
  The usual issue I see is the following with a daily scheduled job:
  
  * cron run starts at 1:00:00
  * there are a bunch of things to do, so it gets to the daily job at 1:00:20
  * the next day at 1:00:00, cron runs again
  * there's less to do, so it gets to the daily scheduled job at 1:00:10
  * being "daily", the scheduled job checks to make sure its previous run was more than one day ago, and that check fails since it was 23 hours, 59 minutes, 50 seconds ago
  * the scheduled job executes the next time cron runs
  
  In my experience, that would normally make the scheduled job walk one cron interval (usually 5, 6, 10, or 15 minutes) rather than an entire hour. However, if you only have the cron job running hourly, that would explain your phenomenon exactly.
  
  Unfortunately, there's no way to guarantee that a scheduled job will get run at a precise time each day unless you have a separate cron job to run the single scheduled job. However, reducing the cron interval will mean that when the schedule job does walk, it'll take smaller steps.
  
  *(Side note: this situation is why I always have the scheduled reminders job run hourly rather than daily. Otherwise, the scheduled job might walk all the way to 11:00 pm, potentially reminding people about the next day's event after the recipients have gone to bed.)*
  
  **UPDATE:** As Karin describes below, this was addressed in 4.6.3, so the later 4.6.x releases all fix this. However, some changes introduced in 4.7 had the result of undoing this. The relevant issue is [CRM-18671](https://issues.civicrm.org/jira/browse/CRM-18671) for describing what's going on.
  
  > **Comments:**
  > **username_0**: Thanks Andrew! I'm hesitant to move this recurring contributions job from daily to hourly - though I understand that would in all likelihood reduce the speed at which these jobs are walking.  
  > **username_0**: So your update explains why this is all working for us on the hours - exactly - for all our 4.6.x-es. Thanks for creating the JIRA issue: https://issues.civicrm.org/jira/browse/CRM-18671  
  > **username_1**: Worth noting, the CronPlus extension (https://lab.civicrm.org/extensions/cronplus) purports to alleviate this problem.  
  
  ---
  
  ### Answer by username_3 on 2020-11-18. Score: 2
  
  This extension might solve this issue: [Cron Plus](https://lab.civicrm.org/extensions/cronplus)
  
  
  ---
  
  ### Answer by username_0 on 2016-05-24. Score: 1
  
  This may actually not be related to Centos7 vs Centos6 but due to the fact that the project in question is still on 4.4 LTS - Looks like this was addressed in 4.6.3: <https://issues.civicrm.org/jira/browse/CRM-16276> - thanks @Allan Shaw!
  
  > **Comments:**
  > **username_2**: Ooh, I didn't know about this fix.  It's for 4.6 only, however--that trick of looking at the hour or day is no longer in effect for 4.7: https://github.com/civicrm/civicrm-core/blob/1e7702fee94c891c1c1b3ec4d43688991f96b6af/CRM/Core/ScheduledJob.php#L154  
  > **username_4**: I do recall seeing this a few years ago but not going down the rabbit hole to diagnose, etc.  
  > **username_0**: @AndrewHunt - shoot I thought I was onto something! :-)  
  
  ---
  
  