3

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

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].