Hello,
I have problems executing a script in ksh with this script named process.sh:
ps -ef | grep process.sh | grep -v grep | wc -l | read a
if [ $a -gt 1 ]
then
echo "The script is running"
exit 0
fi
The problem is that when I execute the script, sometimes it shows the message "The script is running", when I think it's impossible.
The reason that I write "wc -l|read a" is that
the count returns 1 because the "ps" is executed in the same script. My idea is that nobody execute 2 times the same script, only on time.
Is something wrong?
Thanks in advance.
I have problems executing a script in ksh with this script named process.sh:
ps -ef | grep process.sh | grep -v grep | wc -l | read a
if [ $a -gt 1 ]
then
echo "The script is running"
exit 0
fi
The problem is that when I execute the script, sometimes it shows the message "The script is running", when I think it's impossible.
The reason that I write "wc -l|read a" is that
the count returns 1 because the "ps" is executed in the same script. My idea is that nobody execute 2 times the same script, only on time.
Is something wrong?
Thanks in advance.