linux if使用记录,脚本如下
[root@localhost serviceclient]# cat Check.sh
#!/bin/sh
echo `date`
SecoClientCS=$(ps -ef | grep SecoClientCS | grep -v grep| awk '{print$2}')
echo $SecoClientCS
if [ ! $SecoClientCS ];then
echo "SecoClientCS is not alive"
cd /usr/local/SecoClient/serviceclient/
nohup sh VpnStart.sh &
sleep 5
SecoClientCS1=$(ps -ef | grep SecoClientCS | grep -v grep| awk '{print$2}')
if [ ! $SecoClientCS1 ];then
echo "SecoClientCS start failed"
else
echo "SecoClientCS start sucess"
fi
else
echo "SecoClientCS is alive"
fi
[root@localhost serviceclient]#