Please help me with this question
I have a tantan.sh under /home/mydir which is a caller to another script "tantan.sh" under /home/anotherdir
-----------------------------------------------------------
/home/mydir/tantan.sh
------------------------------------------------------------
#!/bin/sh
echo "caller script
/home/anotherdir/tantan.sh
exit 0
-----------------------------------------------------------
/home/anotherdir/tantan.sh
-----------------------------------------------------------
#!/bin/sh
echo "actual script"
ps -ef |grep tantan.sh | grep -v grep|awk '{print $2}'
for PID in `ps -ef | grep "tantan.sh" | grep -v "grep" |awk '{print $2}'`
do
echo $PID
done
This always echos 3 PIDs and not two. My requirement is to see, that if there are two or more tantan.sh process initiated, then exit. Only one tantan.sh must be there at any time, parellel processing is not supported.
I was thinking to go this way, if there is any other process other than the currentPID and parent PID, then exit, but since the ps command returns three PIDs, I am not able to get a solution, please advice.