shell | 已知进程查找命令

Linux端进程运行状态查找

查找正在运行的程序: ps -aux
遍历查找是否存在已知进程: ps -aux | grep proc_str
查找结果中只显示有效的查找信息: ps -a -ocomm | grep proc_str

Exp:

脚本编写: #!/bin/sh
while [ 1 ] ; do
ps -aux | grep pppd |grep -v grep
if [ $? -ne 0 ] ; then
/#Run the condition while the process pppd is not exist.
/#Add condition here...
fi
/#Loop time.
sleep 30
done

说明:$? -ne 0 不存在,$? -eq 0 存在
具体介绍参考链接:https://blog.csdn.net/Jessica_hhh/article/details/70257624

posted @ 2021-04-01 17:28  CristL  阅读(123)  评论(0编辑  收藏  举报