博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
shell判断一个进程是否存在,如果不存在重启该进程
阅读量:4056 次
发布时间:2019-05-25

本文共 720 字,大约阅读时间需要 2 分钟。

Linux下编程实例

判断一个进程是否存在,如果不存在重启该进程:

#!/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 $countsec=7#开始一个循环,以判断进程是否关闭for var in 1 2do  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  fidone#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 &

转载地址:http://fxoci.baihongyu.com/

你可能感兴趣的文章
JSX使用总结
查看>>
React Native(四):布局(使用Flexbox)
查看>>
React Native(七):Android双击Back键退出应用
查看>>
Android自定义apk名称、版本号自增
查看>>
adb command not found
查看>>
Xcode 启动页面禁用和显示
查看>>
【剑指offer】q50:树中结点的最近祖先
查看>>
二叉树的非递归遍历
查看>>
【leetcode】Reorder List (python)
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Candy(python)
查看>>
【leetcode】Clone Graph(python)
查看>>
【leetcode】Sum Root to leaf Numbers
查看>>
【leetcode】Pascal's Triangle II (python)
查看>>
java自定义容器排序的两种方法
查看>>
如何成为编程高手
查看>>
本科生的编程水平到底有多高
查看>>
AngularJS2中最基本的文件说明
查看>>
从头开始学习jsp(2)——jsp的基本语法
查看>>