zoukankan      html  css  js  c++  java
  • 启动服务的脚本

    #!/bin/bash
    case $1 in
               start)
                        systemctl start $2
                        ;;
               stop)
                        systemctl stop $2
                        ;;
              restart)
                        systemctl restart $2
                       ;;
              all_restart)
                        LIST="sshd nginx"
                        for i in $LIST
                              do
                                     systemctl restart $i;
                              done
                      ;;
              all_stop)
                        TEST="sshd nginx"
                        for i in $TEST
                               do
                                     systemctl stop $i;
                             done
                      ;;


              *)
                      echo "Usage: $0 {start|stop|restart}"
    esac
                    if [ $? == 0 ]; then
                              echo "======命令执行成功====="
                    else
                              echo "======命令执行失败====="
                    fi
                              echo ======正在检查进程======
    sleep 0.5
    if    [ $1 == "all_restart" ]; then
        NEM=$(ps -ef | grep $i | grep -vc grep)
                if [ $NEM -gt 1 ]; then
                     echo "$LIST 启动成功"
               else
                     echo "$LIST 启动失败"
    fi
    elif  [ $1 == "all_stop" ]; then
          NAM=$(ps -ef | grep $i | grep -vc grep)
                  if [ $NAM -lt 1 ]; then
                       echo "$TEST 停止服务成功"
              else
                       echo "$TEST 停止服务失败"
                  fi
    else
          NUM=$(ps -ef | grep $2 | grep -vc grep)
                 if [ $NUM -gt 1 ]; then
                      echo "$2 启动成功"            
             else
                      echo "$2 启动失败"
                 fi
    fi

  • 相关阅读:
    8.13实习报告
    8.10实习报告
    8.9实习报告
    8.8实习报告
    8.7实习报告
    关于线索二叉树建立和遍历
    main函数的位置可以任意
    返回指针值的函数和函数指针的区别
    runtime error: store to address 0x625000002048 with insufficient space for an object of type 'double' (solution.c) 0x625000002048: note: pointer points here
    m=-n++
  • 原文地址:https://www.cnblogs.com/zgqbky/p/15336649.html
Copyright © 2011-2022 走看看