Shell implementation to determine if a process exists and restart script sharing _linux Shell

Source: Internet
Author: User
Tags rows count jboss

Concise version:

#! /bin/bash
# author Caoxin
# time 2012-10-10 
# Program: To determine whether to exist and restart


function check () {
  count= ' PS -ef |grep |grep-v "grep" |wc-l
  #echo $count
  if [0 = $count];then nohup python/runscript/working/$1
    & amp;
  Fi
}

check behaviors.py

Detailed version:

 #!/bin/bash # #调用关闭jboss进程脚本 stopmethodserver.sh #打印出当前的jboss进程: grep jboss Query's JBoss process, Grep-v "grep" removes the grep process jmsthread= ' Ps-ef | grep Gdms | grep JBoss | Grep-v "grep" Echo $jmsThread #查询jboss进程个数: Wc-l Returns the number of rows count= ' Ps-ef | grep Gdms | grep JBoss | Grep-v "grep" | Wc-l ' echo $count sec=7 #开始一个循环 to determine if the process closes for VAR in 1 2 does if [$count-gt 0]; Then #若进程还未关闭, the script sleep for a few seconds $sec second the $var time, the JMS thread was still alive sleep $sec else #若进程 has been closed, then out of circulation echo "break" The break fi did #if [$count-eq 0]; Then # echo "Nohup startmethodserver.sh &" # nohup startmethodserver.sh & #else # echo "It" better to check the T Hread!!! "#fi #调用启动脚本 nohup startmethodserver.sh & 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.