zoukankan      html  css  js  c++  java
  • service脚本的写法

    /etc/init.d/appservice.sh内容如下:
    #!/bin/bash
    # chkconfig: 2345 20 80
    # description:
    # For SELinux we need to use 'runuser' not 'su'
    if [ -x "/sbin/runuser" ]; then
        SU="/sbin/runuser -s /bin/sh"
    else
        SU="su -s /bin/sh"
    fi
    fileroot=/opt/cmbccd/repost/
    #program=${fileroot}"start-appservice.sh"
    pidfile=${fileroot}"repost.pid"
    case "$1" in
    start)
        echo "starting repost..."
            if [ -f $pidfile ];
        then
            echo "service is running!"
            echo "[fail]"
        else
            #sh $program
            $SU kafka -c ${fileroot}"start-appservice.sh"
            echo "[success]"
            fi
        ;;
    stop)
        if [ -f $pidfile ];
        then
            pid=$(cat $pidfile)
            echo "stopping service,the pid is:" $pid
            echo $(kill -9 $pid)
            echo $(rm -r $pidfile)
            echo "[success]"
        else
            echo "service is stopped!"
            echo "[fail]"
        fi
        ;;
    status)
        if [ -f $pidfile ];
        then
            pid=$(cat $pidfile)
            echo "service is running,pid is:" $pid
        else
            echo "service is stopped!"
        fi
        ;;
    *)
        echo "Usage: $0 {start|stop|status}"
        exit 1
    esac

  • 相关阅读:
    HBase in Action前三章笔记
    关于视频YUV
    23种设计模式用英语怎样表达?
    UVA 10620
    工具,帮助我们更高效的工作
    VS下控制台执行保持(不要一闪而过)
    C语言之结构体
    Linux grep命令和正则表达式
    C#中的“静态”
    推荐一个计算机视觉图书:python计算机视觉编程
  • 原文地址:https://www.cnblogs.com/dotagg/p/6744285.html
Copyright © 2011-2022 走看看