ssh wait for script to finish

1.9k Views Asked by At

I am using the following script to start a process on a node. from the main node:

for dir  in  n9 n18 n27 n40
do

node=compute-2-10

ssh $node "cd $dir ; nohup ./process.sh >  WATCHDOG-$dir &"

done

the thing is that when I connect to compute-2-10 I see no jobs running. I think that the problem is that the process can not be completed since bash doesn't wait for it to finish. Is this correct or do I need to do something else?

1

There are 1 best solutions below

1
PradyJord On

I have been using something like

ssh $node "nohup myprogram > prog.out 2> prog.err < /dev/null &"

If you redirect all three I/O then this should not create any issue.