Linux带参数的脚本示例(包含进程状态判断)
#!/bin/bash
if [ "$1" == "start" ];then
echo "start"
elif [ "$1" == "stop" ];then
echo "stop"
elif [ "$1" == "status" ];then
while [ 1 ]
do
if [ "`ps -ef | grep ping | grep -v grep`" != "" ];then
echo "running"
else
echo stop
fi
sleep 1s
done
else
echo "error"
fi