bobinindia Posted March 16, 2008 Share Posted March 16, 2008 How to get a script to run regularly or simply in 5 minutes from the end of another script? Quote Link to comment Share on other sites More sharing options...
leeandrew Posted March 16, 2008 Share Posted March 16, 2008 im also looking for a script that works on set time. In my case i want a script to collect data from fields every week, and then save that data to archive, before finally reseting the values it has collected, to be accumulated again for another week. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 16, 2008 Share Posted March 16, 2008 crontab Quote Link to comment Share on other sites More sharing options...
unsider Posted March 16, 2008 Share Posted March 16, 2008 I'd say your best solution is google for this one, and I believe JS has a function that allows for a timed execution. (First problem). The second problem could be done with PHP, but as to how, I do not know. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 16, 2008 Share Posted March 16, 2008 there are at least 2 practical solutions and 1 silly solution. practical: 1. use crontab to run your scripts whenever you want 2. run a script any time someone accesses your site that checks to see if it's time to run the other scripts. this isn't very precise and much more difficult to code than just having crontab run the scripts whenever you want them to run. silly: 3. create a script that always runs, checking to see if it's time to do other stuff. when it's time to do other stuff, it does it, else it keeps looping or sleep()-ing forever. you'd essentially be re-creating crontab very inefficiently. Quote Link to comment Share on other sites More sharing options...
bobinindia Posted March 16, 2008 Author Share Posted March 16, 2008 Your second practical option is fine for me if (date("D")=="31") { $dir = "images/changer/"; function empty_dir ($dir) { $files = glob($dir."*"); foreach($files as $file) { if(is_dir($file)) { if($file != "." && $file != "..") empty_dir($dir.$file."/"); } else unlink($file); } } empty_dir($dir); } Adequate for my needs. By the way do you know how to mark a topic as solved? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.