如何编写一个shell脚本查看某个进程是否在运行
2个回答
展开全部
嘿嘿:)工作代码,权当例子。看看就明白了。
#!/bin/sh
# Deamon Check Program in U51
# including :
# 1.alarm(above & Motorola & EMX2500 & Alcatel; 2.connect_EMX)
#
while [ 1 ]
do
#for i in $ABOVE_DAEMON
cat $1|while read pathname appname
do
ps -ef |grep -v "grep"|grep "$appname" |awk '{print "echo ",$8,$9}'> check_file
if test -s check_file
then
echo $appname "\t\tis running"
else
cd $pathname
$appname &
if [ $? -ne 0 ]
then
echo "Run '$appname' failed!"
break
else
echo "start '$appname' successed!"
fi
fi
done
echo "-----------------------------------------------------------------\n"
echo "-----------------------------------------------------------------\n\n"
sleep 60
done # done of while
#!/bin/sh
# Deamon Check Program in U51
# including :
# 1.alarm(above & Motorola & EMX2500 & Alcatel; 2.connect_EMX)
#
while [ 1 ]
do
#for i in $ABOVE_DAEMON
cat $1|while read pathname appname
do
ps -ef |grep -v "grep"|grep "$appname" |awk '{print "echo ",$8,$9}'> check_file
if test -s check_file
then
echo $appname "\t\tis running"
else
cd $pathname
$appname &
if [ $? -ne 0 ]
then
echo "Run '$appname' failed!"
break
else
echo "start '$appname' successed!"
fi
fi
done
echo "-----------------------------------------------------------------\n"
echo "-----------------------------------------------------------------\n\n"
sleep 60
done # done of while
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询