Linux.com

Home Linux Community Forums Software Command Line Why my shell script is always "stopped" ?

Why my shell script is always "stopped" ?

Link to this post 27 May 09

This is the problem that drives me crazy. I let a script A (a.sh) call script B (b.sh).
I used

 nohup a.sh &>/tmp/log &

In script A it calls B directly, without any redirecting or nohup or background.

Script A:

#do nothing but call B
ssh another-machine "/user/tom/b.sh"

Script B:

# do some fancy things, takes about 1 hour to finish
...

I used

nohup a.sh &>/tmp/log &

It was "stopped" after 5 minutes but B was running and B finished correctly.

Anybody knows why?

BTW, if I don't use nohup and backgrounding, it's OK. i.e. if I use

a.sh

directly. Everything is OK. I am totally confused.

Link to this post 19 Jun 09

Have you check if this is just the ssh session timing out on your remote machine?

You are calling the program with nohup, but that applies locally, doesn't it?

Link to this post 20 Jun 09

ssh requires that stdin, stdout, and stderr (all the stdio stuff) be associated with a valid file or device handle. When you run in the foreground, it will take these from the shell (the tty you are running on). When run in the background, there is no stdin, so in your case you will need to redirect the input. If the file "/user/tom/b.sh" is on your local machine, then try this


ssh another-machine <"/user/tom/b.sh"

in order to redirect stdin appropriately. Don't know if it will work for sure, but it should.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board