start-stop-daemon自动启动、关闭后台程序参数传递
2017-10-11 15:35
1946 查看
/************************************************************************* * 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
相关文章推荐
- 让Java程序作为linux的Daemon后台运行 和 使用Java Service Wrapper将java程序作为linux服务并且开机自动启动
- 使用commons-daemon启动、关闭java程序
- 以&运行在后台的程序,关闭terminal后,相应进进程自动关闭
- C# 向Main函数传递参数(程序启动时传递参数)
- linux 通过命令行在后台启动程序。当命令行窗体关闭时,程序不会被关闭
- 以&运行在后台的程序,关闭terminal后,相应进进程自动关闭
- 用start-stop-daemon启动Nginx
- 微信小程序POST请求参数传递不到后台解决方案
- 【整理】解决Linux关闭终端(关闭SSH等)后运行的程序或者服务自动停止【后台运行程序】
- 【原創】關於C#程序調用Process.Start并获得启动参数的問題
- Dos批处理 Start命令的参数 - bat运行完批处理文件自动关闭窗口
- 怎样给JS写的function传递后台程序中的参数?
- _03_启动程序传递参数_并显示参数
- 定时自动启动外部应用软件并限时关闭此软件程序
- linux_后台启动多个java -jar 程序,及关闭
- 〖Linux〗以后台方式启动/结束指定程序/命令(不受 exit 或点击窗口关闭按钮等终端退出操作的影响)
- windows用bat命令启动程序并传递参数
- 使用start-stop-daemon工具来启动hudson slave
- windows用bat命令启动程序并传递参数
- 请用Shell编程来实现:当输入不同的选择时,执行不同的操作,如:输入start 开始启动应用程序myfiles,输入stop时,关闭myfiles,输入status时,查看myfiles进程,否则执