Hi All,
I have a peculiar requirement as follows,
I have a some hosts on which i have to run a script, so i am using the following code piece
for i in $HOSTLIST
do
ssh ${i} "~/task.sh"
done
Now i want to run this same thing in parallel on all the hosts and then monitor the ssh process and also get the appropriate process exit status and i want to log the same so i tried the following
for i in $HOSTLIST
do
ssh ${i} "~/task.sh"
echo "${i}:$!" > process.file
done
for line in `cat process.file`
do
#Assuming i have extracted pid value using cut
pid=`echo ${line}|cut -d ":" -f2`
wait "${pid}"
echo "$? - Status for ${pid}" > Status.file
done
The error i am getting now i sthe status is alwaus logged as 127 and the log shows
wait: pid <PID> is not a child of this shell
Also the ssh script is run in flow as follows
1.sh -> 2.sh ->3.sh(script which has ssh code in it)
Any help on this will be highly appreciated...
TIA
---------- Post updated at 02:52 PM ---------- Previous update was at 02:33 PM ----------
Anyone has any idea about it?