I need to run a ksh script on around 200 servers(consisting of AIX,LInux,HP-UX,Solaris). The script is there in the /tmp directory of all the servers. I want want to execute the script in background on the respective servers and then exit from there. I have written something like below:
for i in `cat Server_List`
do ssh -q $i "nohup ksh /tmp/script.ksh -E &"
done
But i want the for loop to execute the remote script and then exit and proceed to the next server in Server_List.
For this i wrote:
for i in `cat Server_List`;
do ssh -q $i < "ksh /tmp/script.ksh -E &; exit";
done
But i am getting errors like below:
bash: ksh /tmp/script.ksh -E &; exit: No such file or directory
bash: ksh /tmp/script.ksh -E &; exit: No such file or directory
.... .... ..... ..... ...... ......
Can someone help me in creating a script that serves my objective.
The -x closes X11 connection.
The -n closes stdin; stdout and stderr is closed at the remote side.
The ksh -c wrapper is to ensure that >/dev/null 2>&1 works even if login shell were a C-Shell.
The sleep 1 is best practice (allows to ^C interrupt, avoids problem with too fast socket allocation, ...)
I think nohup is not needed here. -E option is not portable - specific to Linux/pdksh?
Also, i want to invoke the script in background on the respective servers and then exit from there and then proceed to the next server on the list, i dont want the script to wait for finishing on one server and then proceed to the next.