使用下列代码判断程序sh test.sh是否在后台执行!
sh test.sh
#!/bin/sh count=`ps aux | grep -v grep | grep "sh test.sh" | wc -l` echo $count if [ $count -ge 1 ] ; then echo "faild" exit else sleep 40 fi echo "end"