• 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
  • 相关阅读:
    Navi.Soft31.WinForm框架(含下载地址)
    Navi.Soft31.阅读导航
    工作流组件示例(全部开源)
    WinForm中播放视频示例(含源码)
    angularjs实现选项卡实例
    angularjs中使用 <input type="file">标签实现一次最多上传5张图片
    angularjs笔记《二》
    input type="number"时,maxlength不起作用怎么解决
    笔记——《正则表达式》
    如何区分slice、splice和split
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/7650897.html
Copyright © 2020-2023  润新知