#!/bin/bash
daemonNum=`ps -ef |grep -v "grep" | grep "$0" | wc -l`
if [ $daemonNum -gt 2 ]
then
echo 'The other thread is running, exit!'
exit
fi
echo 'Start doing somthing...'
sleep 10
echo 'finished.'
#!/bin/bash
daemonNum=`ps -ef |grep -v "grep" | grep "$0" | wc -l`
if [ $daemonNum -gt 2 ]
then
echo 'The other thread is running, exit!'
exit
fi
echo 'Start doing somthing...'
sleep 10
echo 'finished.'