View Full Version : Background process
stevewi
08-15-2006, 01:01 PM
I'm trying to run a background task and it keeps dying. If I SSH into the site and start it, it runs fine. But once I exit the shell, it will eventually die. I also try to start it via the webserver. Same effect, runs for a few minutes and then disappears.
It's a PHP script that I call either via commandline or a system call from another script like:
php myscript.php >/dev/null &
I get no indication as to why it quits. Anyone got any ideas?
Thanks,
Steve
PS.
I've submitted a ticket to support, but so far all they've done is close it without answering it. I'm trying to get it reopened for the 3rd time now. Also, I ran this same script last year with no problems.
redsox9
08-15-2006, 01:03 PM
Is this a candidate for a cron job?
stevewi
08-15-2006, 01:15 PM
I was going to run a cron job that would check to see if the process was running and start it if it wasn't, but it's only running for a minute or two. It needs to be running all the time (for a few weeks anyhow). It's part of a fantasy soccer website and this function supports an online draft. The script runs in a while(1) loop, queries/updates some db tables, sleeps(5) and does it again. For the draft to work, it must be running.
stevewi
08-17-2006, 08:14 AM
Nobody has any ideas? Still not getting any help from support.
dkinzer
08-17-2006, 09:07 AM
The script runs in a while(1) loop, queries/updates some db tables, sleeps(5) and does it again.
Wouldn't you achieve same result if the script had no loop but you ran it via cron every 5 seconds?
Smoothice
08-17-2006, 10:25 AM
PHP has a time out of 5 minutes. You can not run a script longer than that. This might help you.
Smoothice
stevewi
08-17-2006, 01:26 PM
According to the doc on php.net, php cli overrides the php.ini setting of max_execution_time, setting it to 0 because "it does not make sense in shell environments". Plus, if I start it from SSH, it runs fine either background or foreground.
lazynitwit
08-17-2006, 06:11 PM
Unless you have your own IP address, processes should be terminated automatically after a period of time if I remember correctly.
Try making it execute 12 times and making a cronjob that runs every minute.
stevewi
08-18-2006, 08:05 AM
Thanks. That's the kinda of info I'm looking for from support. So far, nothing after 9 days.
aceofspades
08-18-2006, 08:39 AM
yah it says "If you wish to run a script for more than 5 minutes you must buy a dedicated IP. If it is a low resource script just use a cron job.
yvovandoorn
08-19-2006, 05:12 PM
If its truly dying after you disconnect, you could use GNU Screen (which is installed on the box I am hosted on).
Yvo
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.