Monday, July 1, 2024

Cron run every which is set the time.

 /**

 * Implements hook_cron().
 */
function sso_user_cron() {
  //$current_time = time() + 6*60*60; 6hr total=21600,12hr total=43200,24hr total=86400, ;
  $current_time = time();
  $state = \Drupal::state();
  $last_update_state = 'sso_user.last_update';
  $last_update= $state->get($last_update_state, 0);
  //every 24hr run the cron.
  if ($current_time - $last_update > 21600) {
    \Drupal::service('sso_user.user')->batchCloseDateMail();
    \Drupal::state()->set($last_update_state, $current_time);
  }
}





/** * Implements hook_cron(). */ function sso_user_cron() { //$current_time = time() + 6*60*60; 6hr total=21600,12hr total=43200,24hr total=86400, ; $current_time = time(); $state = \Drupal::state(); $last_update_state = 'sso_user.last_update'; $last_update= $state->get($last_update_state, 0); //every 24hr run the cron. if ($current_time - $last_update > 21600) { \Drupal::service('sso_user.user')->batchCloseDateMail(); \Drupal::state()->set($last_update_state, $current_time); } }

No comments:

Post a Comment

If you have any problem please let me know.