Jump to content

Keep Script Always Running


N-Bomb(Nerd)

Recommended Posts

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

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.

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.