phatfish
03-21-2010, 10:19 PM
Hi there,
I have a simple shell script that I want to keep running indefinitely without leaving a putty window open. I've tried several different methods (non-specific to bluehost) and have had mixed results.
Both when I use nohup or trying to double fork the process into the background the script seems to run for a while (perhaps a min or two) after I close my putty session and then mysteriously stops (I've been using ps -u to check this). These are the commands I've been using for that:
nohup script.sh &
sh -c script.sh >/dev/null 2>&1 &"
Either one of these works fine as long as I leave my putty window open.
The method I've had the best luck has been by using the screen command. With this my script will run for a number of days before the process is killed/stoped/etc.
Screen
script.sh
I can x out of my putty window, but the process will remain active for a number of days before I discover that I can no longer connect to my screen.
I get something like this when I try to reconnect with screen -r
There is a screen on:
20351.pts-1.box654 (Dead ???)
Remove dead screens with 'screen -wipe'.
There is no screen to be resumed.
I wonder if this is all part of some automated bluehost cleanup or some such activity to kill processes left going after a user logs out. I've thought about trying to use a cron job to check if my script isn't running, and start it if it isn't, but this seems like overkill. There must be some way to simply start a process and have it continue to run. Any ideas?
It looks like people trying to use teamspeak are running into the same problem where their process will simply stop running.
http://www.bluehostforum.com/showthread.php?t=19240
http://www.bluehostforum.com/showthread.php?t=19851
I have a simple shell script that I want to keep running indefinitely without leaving a putty window open. I've tried several different methods (non-specific to bluehost) and have had mixed results.
Both when I use nohup or trying to double fork the process into the background the script seems to run for a while (perhaps a min or two) after I close my putty session and then mysteriously stops (I've been using ps -u to check this). These are the commands I've been using for that:
nohup script.sh &
sh -c script.sh >/dev/null 2>&1 &"
Either one of these works fine as long as I leave my putty window open.
The method I've had the best luck has been by using the screen command. With this my script will run for a number of days before the process is killed/stoped/etc.
Screen
script.sh
I can x out of my putty window, but the process will remain active for a number of days before I discover that I can no longer connect to my screen.
I get something like this when I try to reconnect with screen -r
There is a screen on:
20351.pts-1.box654 (Dead ???)
Remove dead screens with 'screen -wipe'.
There is no screen to be resumed.
I wonder if this is all part of some automated bluehost cleanup or some such activity to kill processes left going after a user logs out. I've thought about trying to use a cron job to check if my script isn't running, and start it if it isn't, but this seems like overkill. There must be some way to simply start a process and have it continue to run. Any ideas?
It looks like people trying to use teamspeak are running into the same problem where their process will simply stop running.
http://www.bluehostforum.com/showthread.php?t=19240
http://www.bluehostforum.com/showthread.php?t=19851