1

cron

cron_run
SYNOPSIS

cron_run()

DESCRIPTION
CODE
  1. require_once 'registry.php';
  1. define('CRON_DIR', ROOT_DIR . DIRECTORY_SEPARATOR . 'cron');
  1. function cron_run() {
  2.     $files=glob(CRON_DIR . DIRECTORY_SEPARATOR . '*.php');
  3.  
  4.     if (!$files) {
  5.         return true;
  6.     }
  7.  
  8.     $now=time();
  9.  
  10.     $semaphore = registry_get('cron_lock', false);
  11.  
  12.     if ($semaphore) {
  13.         if ($now - $semaphore < 3600) {
  14.             return false;
  15.         }
  16.     }
  17.  
  18.     registry_set('cron_last', $now);
  19.     registry_set('cron_lock', $now);
  20.  
  21.     foreach ($files as $f) {
  22.         include $f;
  23.     }
  24.  
  25.     registry_delete('cron_lock');
  26.  
  27.     return true;
  28. }
cron_cleanup
SYNOPSIS

cron_cleanup()

DESCRIPTION
CODE
  1. function cron_cleanup() {
  2.     registry_delete('cron_lock');
  3. }
SEE ALSO

registry, index

Comments

To add a comment, click here.