如何编写一个shell脚本查看某个进程是否在运行
答案:2 悬赏:0 手机版
解决时间 2021-11-30 01:14
- 提问者网友:wodetian
- 2021-11-29 06:36
如何编写一个shell脚本查看某个进程是否在运行
最佳答案
- 五星知识达人网友:廢物販賣機
- 2021-11-29 06:49
嘿嘿:)工作代码,权当例子。看看就明白了。
#!/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
全部回答
- 1楼网友:纵马山川剑自提
- 2021-11-29 07:28
脚本名:a.sh
ps aux | grep a.sh
ps aux | grep a.sh
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯