Re: Background jobs from ssh



On Fri, 16 Feb 2007 13:28:34 -0600, Bit Twister wrote:
On 16 Feb 2007 10:42:41 -0800, jhavero@xxxxxxxxx wrote:
However, my plink command won't return util the background jobs have
finished. I don't want my
ssh client to have to wait. Is there any way around this?

man nohup

That's not the whole story. The summary line for nohup ends with,
"...with output to a non-tty". The OP ran his job attached to a tty
as

job1 &

With nohup, the job won't get sent SIGHUP when the terminal
closes. However, if the job attempts to write to either stdout
or stderr, it may stop with SIGTTOU, then hang or die because
the original terminal is gone.

For a command that doesn't read stdin, the right way to run the
job would be one of the following:

nohup job1 > /dev/null 2>&1 &
nohup job1 > /dev/null 2> /dev/null &

nohup job1 > job1.log 2> job1.err &

You could also send the error stream to the log file instead
of a separate file, but I like to see the nice, empty error
file if the job ran correctly.

nohup job1 > job1.log 2>&1 &

If job1 might want input from the keyboard, you would have to
use one of the above with stdin redirect in from elsewhere also.


Another way, if you have it available, is to use "screen". It works
well for some usage scenarios, but may not be applicable to your
situation. Linux Journal did an article on it a while back:
http://www.linuxjournal.com/article/6340 and google lists other
tutorials and introductions.


Mike

--
Michael Zawrotny
Institute of Molecular Biophysics
Florida State University | email: zawrotny@xxxxxxxxxx
Tallahassee, FL 32306-4380 | phone: (850) 644-0069
.