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

  • 相关阅读:
    多线程交替打印示例
    单列集合框架体系Collection
    同域名下,两个网站通过cookie共享登录注册功能大概思路。
    CSS 隐藏滚动条
    Vue3--组件间传值
    TypeScript--类(class)
    TypeScript--泛型(generic)
    理解LDAP与LDAP注入
    CRLF injection 简单总结
    pigctf期末测评
  • 原文地址:https://www.cnblogs.com/dotagg/p/6744285.html
Copyright © 2011-2022 走看看