Shell实现判断进程是否存在并重新启动脚本
来源:互联网 发布:网络女歌手排行榜甜美 编辑:程序博客网 时间:2024/05/16 07:50
简洁版:
#! /bin/bash # author caoxin # time 2012-10-10 # program : 判断进行是否存在,并重新启动 function check(){ count=`ps -ef |grep $1 |grep -v "grep" |wc -l` #echo $count if [ 0 == $count ];then nohup python /runscript/working/$1 & fi } check behaviors.py
详细版:
#!/bin/bash # #调用关闭jboss进程脚本 stopMethodServer.sh #打印出当前的jboss进程:grep jboss查询的jboss进程,grep -v "grep" 去掉grep进程 jmsThread=`ps -ef | grep gdms | grep jboss | grep -v "grep"` echo $jmsThread #查询jboss进程个数:wc -l 返回行数 count=`ps -ef | grep gdms | grep jboss | grep -v "grep" | wc -l` echo $count sec=7 #开始一个循环,以判断进程是否关闭 for var in 1 2 do if [ $count -gt 0 ]; then #若进程还未关闭,则脚本sleep几秒 echo sleep $sec second the $var time, the JMS thread is still alive sleep $sec else #若进程已经关闭,则跳出循环 echo "break" break fi done #if [ $count -eq 0 ]; then # echo "nohup startMethodServer.sh &" # nohup startMethodServer.sh & #else # echo "It's better to check the thread!!!" #fi #调用启动脚本 nohup startMethodServer.sh &
0 0
- Shell实现判断进程是否存在并重新启动脚本
- shell脚本判断进程是否存在,并重新启动
- shell脚本判断进程是否存在,并重新启动
- shell脚本循环判断进程是否存在
- shell脚本判断Apache进程是否存在
- shell脚本中判断进程是否存在
- linux下如何自动检测并重新启动一个死掉的进程(shell脚本实现)
- shell脚本判断/dev/ttyUSB0是否存在
- shell脚本判断设备节点是否存在
- shell 脚本判断文件是否存在
- shell 脚本判断某个文件是否存在
- shell脚本中判断文件是否存在
- shell脚本判断设备节点是否存在
- 判断文件是否存在 shell 脚本
- shell 脚本判断文件、文件夹是否存在
- shell脚本判断文件是否存在
- shell:判断一个进程是否存在
- linux shell 判断进程是否存在
- OC - 集合
- 转载:基于Mesos和Docker的分布式计算平台
- .NET日志管理方法
- 简单密码
- 一个从QWidget派生的简单类通过setStyleSheet设置背景无效的问题
- Shell实现判断进程是否存在并重新启动脚本
- windows 系统 MySQL_5.6.21安装教程
- 关于C语言创建一个数组的三个方法,其中包含变长数组。
- FreeMarker语法总结
- 如何把一个表单form变成Json对象
- java web文件下载功能实现
- Java - 字符串常用类、方法小结
- Oracle11G密码延迟验证导致的系统HANG住
- 快速排序算法的算法过程