当前位置: 技术问答>linux和unix
求教:linux平台shell命令里写的死循环,开机启动不能进系统
来源: 互联网 发布时间:2017-02-24
本文导语: #!/bin/sh #===================== # # #===================== while : do SmsProcess=$(ps -ef |grep "EMTSmsService" |grep -v "grep") if [ "$SmsProcess" ] ; then echo "SmsProcess service was already started" else echo "SmsProcess service ...
#!/bin/sh
#=====================
#
#
#=====================
while :
do
SmsProcess=$(ps -ef |grep "EMTSmsService" |grep -v "grep")
if [ "$SmsProcess" ] ; then
echo "SmsProcess service was already started"
else
echo "SmsProcess service was not started"
echo "SmsProcess Starting service ..."
.//SmsService
fi
NetProcess=$(ps -ef |grep "EMTNetService" |grep -v "grep")
if [ "$NetProcess" ] ; then
echo "NetProcess service was already started"
else
echo "NetProcess service was not started"
echo "NetProcess Starting service ..."
.//NetService
fi
CtiProcess=$(ps -ef |grep "EMTCtiService4" |grep -v "grep")
if [ "$CtiProcess" ] ; then
echo "CtiProcess service was already started"
else
echo "CtiProcess service was not started"
echo "CtiProcess Starting service ..."
.//CtiService4
fi
sleep 30
done
代码如上,如果在/etc/rc.d/rc.loacal里面直接添加的话,系统启动时候就一直在循环,进不去系统了。如果想要开机启动就执行这段shell命令,有什么好办法吗?
#=====================
#
#
#=====================
while :
do
SmsProcess=$(ps -ef |grep "EMTSmsService" |grep -v "grep")
if [ "$SmsProcess" ] ; then
echo "SmsProcess service was already started"
else
echo "SmsProcess service was not started"
echo "SmsProcess Starting service ..."
.//SmsService
fi
NetProcess=$(ps -ef |grep "EMTNetService" |grep -v "grep")
if [ "$NetProcess" ] ; then
echo "NetProcess service was already started"
else
echo "NetProcess service was not started"
echo "NetProcess Starting service ..."
.//NetService
fi
CtiProcess=$(ps -ef |grep "EMTCtiService4" |grep -v "grep")
if [ "$CtiProcess" ] ; then
echo "CtiProcess service was already started"
else
echo "CtiProcess service was not started"
echo "CtiProcess Starting service ..."
.//CtiService4
fi
sleep 30
done
代码如上,如果在/etc/rc.d/rc.loacal里面直接添加的话,系统启动时候就一直在循环,进不去系统了。如果想要开机启动就执行这段shell命令,有什么好办法吗?
|
你的shell命令里有echo的,那你的Linux应该是有人监控的,你也可以等开机后手动启动……