zoukankan      html  css  js  c++  java
  • start-stop-daemon自动启动、关闭后台程序参数传递

    /*************************************************************************
     *          start-stop-daemon自动启动、关闭后台程序参数传递
     * 说明:
     *     看了使用start-stop-deamon启动脚本,没看到怎么传递参数的,测试一下怎么
     * 使用。
     *                              
     *                                      2017-10-11 深圳 南山平山村 曾剑锋
     ************************************************************************/
    
    一、参考文档:
        1. start-stop-daemon(8)
            http://man7.org/linux/man-pages/man8/start-stop-daemon.8.html
    
    二、传递参数:
        1. -S, --start [--] arguments
                  Check for the existence of a specified process.  If such a
                  process exists, start-stop-daemon does nothing, and exits with
                  error status 1 (0 if --oknodo is specified).  If such a
                  process does not exist, it starts an instance, using either
                  the executable specified by --exec or, if specified, by
                  --startas.  Any arguments given after -- on the command line
                  are passed unmodified to the program being started.
        2. 如上所述,在--之后加入命令行参数:
            start-stop-daemon -S -b -x /usr/sbin/httpd -- -h /var/www
            
    三、示例:
        cat /etc/init.d/S71httpd
            #! /bin/sh
            
            set -e
            
            DESC="httpd"
            NAME=httpd
            DAEMON=/usr/sbin/$NAME
            
            case "$1" in
              start)
                    printf "Starting $DESC: "
                    start-stop-daemon -S -b -x $NAME -- -h /var/www
                    echo "OK"
                    ;;
              stop)
                    printf "Stopping $DESC: "
                    start-stop-daemon -K -x $NAME
                    echo "OK"
                    ;;
              restart|force-reload)
                    echo "Restarting $DESC: "
                    $0 stop
                    sleep 1
                    $0 start
                    echo ""
                    ;;
              *)
                    echo "Usage: $0 {start|stop|restart|force-reload}" >&2
                    exit 1
                    ;;
            esac
            
            exit 0
  • 相关阅读:
    使用60赫兹交流电的关西人
    UI交互细节节选控件使用细则
    PNG button (按钮) files with transparency, for Visual C++ 6.0 and VS2005
    成都第二天:美食
    精力管理与状态转换
    再议“专注”
    成都第一天:印象
    Flash AMF协议
    AS3.0 JSON介绍
    AS3.0 利用AMFPHP与PHP进行通讯 .
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/7650897.html
Copyright © 2011-2022 走看看