Skip to content

Commit

Permalink
Cron
Browse files Browse the repository at this point in the history
Fix to run anytime during a given hour once
  • Loading branch information
protitude committed Jan 27, 2025
1 parent 3fe8a14 commit 9d96ff9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions servicenow.module
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,22 @@ function servicenow_cron() {
$servicenow_api_prod = $config->get('servicenow_api_prod');
if ($servicenow_api_prod) {
// Run 1am.
if ((date('G', time()) == 01) && (date('i', time()) >= 0) && (date('i', time()) < 9)) {
$princess_dead_hour = TRUE;
if (date('G', time()) == 1) {
$settings = \Drupal::service('servicenow.fetch.settings');
$is_reloading = $settings->getpr();
if ($is_reloading === 0) {
$princess_dead_hour = TRUE;
}
}
}
else {
// Run at Midnight.
if ((date('G', time()) == 00) && (date('i', time()) >= 0) && (date('i', time()) < 5)) {
$princess_dead_hour = TRUE;
if (date('G', time()) == 00) {
$settings = \Drupal::service('servicenow.fetch.settings');
$is_reloading = $settings->getpr();
if ($is_reloading === 0) {
$princess_dead_hour = TRUE;
}
}
}

Expand Down

0 comments on commit 9d96ff9

Please sign in to comment.