Sunday, 15 April 2012

linux - Launching multiple processes on different boxes with BASH -



linux - Launching multiple processes on different boxes with BASH -

my script looks like:

#!/bin/bash myprogram1& pidmyprogram1=$! ssh myusername@pluto myprogram2& pidmyprogram2=$! function cleanup { kill -9 $pidmyprogram1 $pidmyprogram2 exit 0 } trap cleanup sigint sigterm while : sleep 1 done

it not work need to. trying launch 2 processes, 1 on box called pluto. want these 2 processes run indefinitely until nail control+c, want both processes stop. when run end ssh'ed pluto, processes aren't running. ideas how can handle requirement of starting process on seperate box? pretty new bash...

ssh myusername@pluto starts shell on remote machine , does not exit until shell exits. not cause remainder of script executed on remote machine. need pass myprogram2 argument ssh; programme must exist on remote machine, not on local box.

myprogram1 & pidmyprogram1=$! ssh myusername@pluto myprogram2 & pidmyprogram2=$! function cleanup { kill $pidmyprogram1 $pidmyprogram2 exit 0 } trap cleanup sigint sigterm while : sleep 1 done

assuming myprogram1 run forever until interrupted, can replace busy while loop with

wait $pidmyprogram1

linux bash ssh process

No comments:

Post a Comment