note 32362 deleted from control-structures.declare by aidan
| From: | aidan@php.net | Date: | Wed, 19 Jan 2005 06:58:33 +0000 |
| Subject: | note 32362 deleted from control-structures.declare by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-83606@lists.php.net to get a copy of this message | ||
Note Submitter: matthias dot huttar at aon dot at
----
CHRONJOBS IN PHP
------------------
A simple replacement for chronjobs on a http server....
Start the file once and then never touch it again. You can control the ticks with the file state.txt
(see code!)
<?php
ignore_user_abort(true); #ein user abbruch lässt das script trotzdem weiterlaufen!
ini_set("max_execution_time",0); #wird nie aufhören
register_tick_function("mychronjobs");
declare(ticks=1)
{
while(1)
{
sleep(60*60);
}
}
function mychronjobs()
{
$file=fopen("state.txt","r");
$contents = fread ($file, filesize ($filename));
if($contents=="run")
{
print "tick ausgeführt";
#Code for Tick here!
}elseif($contents=="shutdown") { exit();}
}
?>
I haven't tested it and it probably won't run on all servers...