note 32362 added to control-structures.declare
| From: | matthias dot huttar at aon dot at | Date: | Sun, 25 May 2003 13:40:55 +0000 |
| Subject: | note 32362 added to control-structures.declare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-48984@lists.php.net to get a copy of this message | ||
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!)
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...
----
Manual Page -- http://www.php.net/manual/en/control-structures.declare.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32362
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32362&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32362&report=yes