监控一个进程是否在执行

来源:互联网 发布:易语言 数组对比 编辑:程序博客网 时间:2024/06/14 03:41
#!/bin/sh 
#查找fsd的pid    
ui=$(ps x |grep mongodb |grep -v grep)   
if [ -z "$ui" ] 
then  
#如果fsd的PID不存在就启动fsd    
/usr/local/mongodb-linux-x86_64-2.0.0/bin/mongod & 
echo "mongodb restart ok.." 
else
echo "mongodb is start!"
fi