N-Bomb(Nerd) Posted May 1, 2009 Share Posted May 1, 2009 Hello, I've made a script that I would like to always have executing. My script uses a loop to keep executing however I can't leave it open in my browser because my internet drops and it times-out. Is there a way I can set my script to run on my server without me going to it in my browser? Link to comment https://forums.phpfreaks.com/topic/156386-keep-script-always-running/ Share on other sites More sharing options...
LOUDMOUTH Posted May 1, 2009 Share Posted May 1, 2009 crons? Link to comment https://forums.phpfreaks.com/topic/156386-keep-script-always-running/#findComment-823338 Share on other sites More sharing options...
N-Bomb(Nerd) Posted May 1, 2009 Author Share Posted May 1, 2009 crons? What if I wanted to stop it from running then considering the script loops after it's started? Link to comment https://forums.phpfreaks.com/topic/156386-keep-script-always-running/#findComment-823339 Share on other sites More sharing options...
LOUDMOUTH Posted May 1, 2009 Share Posted May 1, 2009 well you can set crons to run once per minute, hour, day, month, year. So if you setup your Cronjobs correctly then you would only need to start it once, then can let it loop. then disable your cron job later if need be. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/156386-keep-script-always-running/#findComment-823340 Share on other sites More sharing options...
N-Bomb(Nerd) Posted May 1, 2009 Author Share Posted May 1, 2009 Right, however once I start the script it's going to continue to run. I should only have to set the cronjob once, however even after I delete the job won't the script still be executing in the background? Link to comment https://forums.phpfreaks.com/topic/156386-keep-script-always-running/#findComment-823346 Share on other sites More sharing options...
LOUDMOUTH Posted May 1, 2009 Share Posted May 1, 2009 Then I would set cronjob to run once and then make the looping script only LOOP or REFRESH the number of times you are looking for. I assume its a script you want to run while you sleep and then stop once you are back at your machine? Link to comment https://forums.phpfreaks.com/topic/156386-keep-script-always-running/#findComment-823349 Share on other sites More sharing options...
N-Bomb(Nerd) Posted May 1, 2009 Author Share Posted May 1, 2009 Then I would set cronjob to run once and then make the looping script only LOOP or REFRESH the number of times you are looking for. I assume its a script you want to run while you sleep and then stop once you are back at your machine? Well it's always looping/refreshing to check for new content. I only need to have it ran for a few hours a time though, it's not something that I ALWAYS need running.. but there has to be a better way than trying to open it in my firefox and letting it sit there. Link to comment https://forums.phpfreaks.com/topic/156386-keep-script-always-running/#findComment-823353 Share on other sites More sharing options...
LOUDMOUTH Posted May 1, 2009 Share Posted May 1, 2009 To monitor your running scripts I would check out Hobbit http://hobbitmon.sourceforge.net/ This will let you rest easy while you have your stuff running. "nohup" and "screen" also check out http://www.felixgers.de/teaching/internet/nohup.html I would start the process with Crons then KILL process with something like this <?php $time = time(); .... while($data){ if((time()-$time) > 1400) exit; //do some processing } That will run it for 4 hours after crons starts it then KILL it. Link to comment https://forums.phpfreaks.com/topic/156386-keep-script-always-running/#findComment-823379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.