我需要为 IRC 记录器创建一个初始化脚本。我复制了/etc/init.d/skeleton。我填写了配置部分以满足我的需要,并且我还必须将 --background 添加到 start daemon 命令,因为我的 IRC 记录器不会分离。当我使用我的 init 脚本时,记录器可以正常启动,但它不会像它应该的那样创建 .pid 文件。因此,除非我自己找出进程 ID 并杀死它,否则进程无法停止。这是脚本:
#! /bin/sh
### BEGIN INIT INFO
# Provides: skeleton
# Required-Start: $remote_fsh
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
# Author: Cory Walker <cwalker32@gmail.com>
#
# Please remove the "Author" lines above and …
Run Code Online (Sandbox Code Playgroud) 我需要start-stop-daemon
为一个 redis 实例运行一个,我希望它发送一个SIGTERM
,如果 redis 实例没有退出,我希望它强制退出。
该start-stop-daemon
配置表示,该--retry
选项可用于这一点,但我想不出一个办法做到这一点,这是我目前的命令:
/sbin/start-stop-daemon --stop --retry forever/TERM --quiet --oknodo --pidfile /var/run/redis/redis.pid --exec /usr/bin/redis-server
Run Code Online (Sandbox Code Playgroud)
关于我如何能够做到这一点的任何提示?
我正在尝试openconnect
通过使用以下内容的 Debian init 脚本启动start-stop-daemon
:
DAEMON=/usr/sbin/openconnect
DAEMON_ARGS="<endpoint> --script /etc/vpnc/vpnc-script --user <user> --pid-file $PIDFILE --passwd-on-stdin"
PASSWORD=`cat /etc/openconnect/<endpoint>.passwd`
start-stop-daemon --start --pidfile "$PIDFILE" --exec "$DAEMON" -- $DAEMON_ARGS <<< ${PASSWORD}
Run Code Online (Sandbox Code Playgroud)
不幸的是,openconnect 在启动期间仍然提示输入密码,因为它似乎无法读取重定向到 stdin 的密码。
有任何想法吗?
启动 php5-fpm 似乎可以工作,但立即检查状态显示它没有运行:
[root@server ~]# service php5-fpm start
php5-fpm start/running, process 4516
[root@server ~]# service php5-fpm status
php5-fpm stop/waiting
Run Code Online (Sandbox Code Playgroud)
即使我能够加载 PHP 页面(意味着 PHP-FPM 必须正在运行),状态有时也会报告为stop/waiting
.
看来,有有正在运行的进程,但这些只是工作进程?
ps -aux |grep php
www-data 3552 0.0 0.7 338108 14960 ? S 05:43 0:00 php-fpm: pool www
www-data 3553 0.0 1.3 338168 27156 ? S 05:43 0:00 php-fpm: pool www
www-data 3554 0.0 1.1 337948 23020 ? S 05:43 0:00 php-fpm: pool www
www-data 3555 0.0 1.0 334108 20644 ? S …
Run Code Online (Sandbox Code Playgroud) 我已经创建了脚本来控制 Fedora28 上 git-daemon 的启动、停止等。我现在试图将这些脚本链接到 systemd 服务,以便 git-daemon 在重启后可用。
主脚本 (gitT) 是...
#!/bin/bash
case "$1" in
'start')
echo "Starting git-daemon"
/home/git/scripts/start.sh >> /home/git/gitT.log
;;
'stop')
echo "Stopping git-daemon"
/home/git/scripts/stop.sh >> /home/git/gitT.log
;;
'restart')
echo "Bouncing git-daemon"
/home/git/scripts/bounce.sh >> /home/git/gitT.log
;;
'status')
echo "Status of git-daemon"
/home/git/scripts/status.sh
;;
*)
echo "`basename $0`: usage: `basename $0` { stop | start | restart | status }"
;;
esac
Run Code Online (Sandbox Code Playgroud)
辅助脚本是...
启动文件
#!/bin/bash
# --------------------------
echo "---------------------"
/usr/bin/git daemon --export-all --enable=receive-pack --verbose --pid-file=/home/git/git-daemon.pid --base-path=/home/git/repos >> …
Run Code Online (Sandbox Code Playgroud)