note 32362 modified in control-structures.declare by didou

From: Date: Tue, 10 Jun 2003 15:53:51 +0000
Subject: note 32362 modified in control-structures.declare by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-50113@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... --was-- 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... http://www.php.net/manual/en/control-structures.declare.php

« previous php.notes (#50113) next »