判断进程是否存在的shell代码
判断进程是否存在,使用命令ps、grep、sed、awk。
代码chk_ps.sh:
#!/bin/bash
pid=`ps aux|grep -v grep|grep -v "test.sh"|grep $1|sed -n '1P' | awk '{print $2}'`
if [ -z $pid ];then
echo "there isn't this process!"
else
echo $pid
fi
您可能感兴趣的文章:
shell根据pid判断进程是否存在
判断进程是否存在的shell代码
学习linux shell中 if else以及大于、小于、等于逻辑表达式
shell判断文件是否存在(模板)的一段代码
shell条件测试之test语句的用法
shell判断文件,目录是否存在或具有权限的脚本
shell脚本判断文件相关属性的方法总结
判断文件是否存在的shell脚本
shell判断文件是否存在的方法
用于判断字符串之间是否存在包含关系的shell脚本