Linux 更新rc.d disable/remove不会删除etc/init.d/rc*引用
我已经使用Debian init.d框架创建了一个守护进程,它作为服务成功运行。我还使用了:Linux 更新rc.d disable/remove不会删除etc/init.d/rc*引用,linux,daemon,startup,Linux,Daemon,Startup,我已经使用Debian init.d框架创建了一个守护进程,它作为服务成功运行。我还使用了: sudo update-rc.d /etc/init.d/pirservice.sh defaults 使守护进程在启动时运行,并在发出shutdown命令时关闭 但是,我尝试使用以下方法删除启动时启动服务: sudo update-rc.d /etc/init.d/pirservice.sh remove sudo update-rc.d /etc/init.d/pirservice.sh dis
sudo update-rc.d /etc/init.d/pirservice.sh defaults
使守护进程在启动时运行,并在发出shutdown命令时关闭
但是,我尝试使用以下方法删除启动时启动服务:
sudo update-rc.d /etc/init.d/pirservice.sh remove
sudo update-rc.d /etc/init.d/pirservice.sh disable
使用以下工具检查完工情况:
ls -l /etc/rc?.d/*pirservice.sh
脚本仍然链接在所有6个rc?.d文件夹中,并且确实在启动时仍然加载
当我尝试使用以下内容时:
sudo update-rc.d /etc/init.d/pirservice.sh remove
sudo update-rc.d /etc/init.d/pirservice.sh disable
我得到以下错误:
update-rc.d: using dependency based boot sequencing
update-rc.d: error: cannot find a LSB script for /etc/init.d/pirservice.sh
我的脚本如下:
#!/bin/sh
# /etc/init.d/pirservice.sh
### BEGIN INIT INFO
# Provides: myservice
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Put a short description of the service here
# Description: Put a long description of the service here
### END INIT INFO
# Change the next 3 lines to suit where you install your script and what you want to call it
DIR=/usr/local/bin/myservice
DAEMON=$DIR/pir.py
DAEMON_NAME=pir
# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
DAEMON_USER=root
# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/$DAEMON_NAME.pid
. /lib/lsb/init-functions
do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --startas $DAEMON
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
restart|reload|force-reload)
do_stop
do_start
;;
status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|restart|status}"
exit 1
;;
esac
exit 0
sudo update-rc.d -f /etc/init.d/pirservice.sh remove
有人能提供一些指导吗?好的。我看不到init脚本有任何明显的错误。因此,我按如下方式强制拆除:
#!/bin/sh
# /etc/init.d/pirservice.sh
### BEGIN INIT INFO
# Provides: myservice
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Put a short description of the service here
# Description: Put a long description of the service here
### END INIT INFO
# Change the next 3 lines to suit where you install your script and what you want to call it
DIR=/usr/local/bin/myservice
DAEMON=$DIR/pir.py
DAEMON_NAME=pir
# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
DAEMON_USER=root
# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/$DAEMON_NAME.pid
. /lib/lsb/init-functions
do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --startas $DAEMON
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
restart|reload|force-reload)
do_stop
do_start
;;
status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|restart|status}"
exit 1
;;
esac
exit 0
sudo update-rc.d -f /etc/init.d/pirservice.sh remove
如果有人能找出我出现LSB错误的原因,我将不胜感激。好的。我看不到init脚本有任何明显的错误。因此,我按如下方式强制拆除:
#!/bin/sh
# /etc/init.d/pirservice.sh
### BEGIN INIT INFO
# Provides: myservice
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Put a short description of the service here
# Description: Put a long description of the service here
### END INIT INFO
# Change the next 3 lines to suit where you install your script and what you want to call it
DIR=/usr/local/bin/myservice
DAEMON=$DIR/pir.py
DAEMON_NAME=pir
# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
DAEMON_USER=root
# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/$DAEMON_NAME.pid
. /lib/lsb/init-functions
do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --startas $DAEMON
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
restart|reload|force-reload)
do_stop
do_start
;;
status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|restart|status}"
exit 1
;;
esac
exit 0
sudo update-rc.d -f /etc/init.d/pirservice.sh remove
如果有人能找出我出现LSB错误的原因,我将不胜感激。手册页上说
更新rc.d[-n][f]名称删除
更新rc.d更新System V风格的初始化脚本链接/etc/rcrunlevel.d/NN*name*,其目标是脚本/etc/init.d/name
所以你应该使用
更新rc.dpirservice.sh禁用
相反。
对于良好的样式,您应该更新INIT INFO
块中的信息。
此外,您还可以删除.sh
扩展名以获得更好的名称。手册页上说
更新rc.d[-n][f]名称删除
更新rc.d更新System V风格的初始化脚本链接/etc/rcrunlevel.d/NN*name*,其目标是脚本/etc/init.d/name
所以你应该使用
更新rc.dpirservice.sh禁用
相反。
对于良好的样式,您应该更新INIT INFO
块中的信息。
此外,您还可以删除.sh
扩展名以获得更好的名称