zoukankan      html  css  js  c++  java
  • Linux简单检查服务运行脚本

    脚本内容如下:

    此脚本含义:检查服务是否运行,在运行则记录日志,不在运行则记录日志并将服务启动

    #!/bin/bash      
    svrnm="tomcat"    //设置服务名称
    time=`date`      //时间
    if ps -ef | grep $svrnm | egrep -v grep >/dev/null    //检查此服务是否正在运行
    then
    echo "$date $svrnm is started!" >> /opt/cklog     //运行则将信息写入日志文件
    else
    echo "$date $svrnm is nostart" >> /opt/cklog      //非运行也写入日志文件
    /opt/apache-tomcat-9.0.26/bin/startup.sh >> /opt/cklog  //将服务运行
    fi

       运行脚本

    使用tomcat进行测试

    服务正常运行时,运行脚本

     

    日志内容

      

      服务未运行时,运行脚本

     

      查看服务 

  • 相关阅读:
    HDU 1159 Common Subsequence 动态规划
    poj2349 Arctic Network
    hdu1596 find the safest road
    poj 1011
    二进制枚举
    codeforces 626E Simple Skewness
    code for 1
    painting fence
    codeforces 797c minimal string
    POJ 3977
  • 原文地址:https://www.cnblogs.com/blxt/p/11635467.html
Copyright © 2011-2022 走看看