View Full Version : [SOLVED] How can I avoid script timeouts over SSH?
altonbr
June 12th, 2008, 08:39 PM
I'm trying to run a script like this:
time ./script.sh /public/ /archives/
but my SSH connection keeps timing out after ~53 minutes (~3200 seconds).
How can I run the shell script in the background so that if my connection gets dropped, it keeps running?
CptPicard
June 12th, 2008, 09:01 PM
man screen
dtmilano
June 12th, 2008, 09:10 PM
or simply
nohup command &
CptPicard
June 12th, 2008, 09:12 PM
But with nohup you'll have to remember to redirect output to file or you'll lose it... right?
dtmilano
June 12th, 2008, 09:14 PM
Not really, nohup automatically appends output to nohup.out ot $HOME/nohup.out if stdout is a terminal.
altonbr
June 12th, 2008, 09:28 PM
What about appending the script with '&'? Does that give it a pid?
dtmilano
June 12th, 2008, 09:41 PM
Strictly, appending nohup command with '&', runs it in the background and returns the prompt.
$ nohup sleep 3600 &
nohup: ignoring input and appending output to `nohup.out'
[1] 9870
$ ps
PID TTY TIME CMD
7978 pts/0 00:00:00 bash
9870 pts/0 00:00:00 sleep
9880 pts/0 00:00:00 ps
$ jobs
[1]+ Running nohup sleep 3600 &
altonbr
June 12th, 2008, 10:08 PM
EDIT: nevermind, the prompt just wasn't showing up until I hit enter a couple of times.
So yeah, that's great! Looks like its doing its thing!
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.