Re: problem with exit while using nohup



when you run any command ending with &, it runs in background, that shell does not wait till it gets over and shell prompt is displayed immediately. have a look at following output

1. dawood-ss-macbook:junk dawood$ nohup ./try.sh &
2. [1] 438
3. dawood-ss-macbook:junk dawood$ appending output to nohup.out

on line 2, it displays job id([1]) and pid (438). you get prompt immediately as on line 3. now shell is waiting to get next input. if you want prompt again hit return. :)


Sumir wrote:
Hi,

I am kinda confused with this, am not sure what is happening

i have a script say test.sh
----------
cat myfile | while read line
do
exit 2
done

echo "out of loop"
-----------

as it is evident, the exit should cause the script to terminate ,hence
producing no output for the script.

now when i run the script as "./test.sh", the behaviour is as
expected.
but when i run it with nohup as "nohup ./test.sh &", the "out of loop"
statement appears in the output, indicating that the exit just gets it
outside the loop but does not exit the program.

any ideas on this ?

.



Relevant Pages