我在服务器停止时执行脚本Ubuntu 14.04.1 LTS
但我只想在shutdown
行为上执行它,而不是在执行时执行它reboot
。
$1
我尝试使用but forreboot
或获取值shutdown
,但它总是发送一条stop
消息
我目前正在运行的脚本:
#! /bin/sh
### BEGIN INIT INFO
# Provides: shutdown
# Required-Start:
# Required-Stop: sendsigs
# Default-Start:
# Default-Stop: 0 6
# Short-Description: shutdown
# Description:
### END INIT INFO
shutdown_script.sh
exit 0
并运行
sudo update-rc.d shutdown_job start 19 0 6 .
答案1
尝试将脚本放在不同的运行级别。
/etc/rc0.d - While system shuts down.
/etc/rcS.d - While system boots
/etc/rc1.d - Working as singel user (user specific on login)
/etc/rc2.d - Working as multiple users
/etc/rc3.d bis /etc/rc5.d - not used in ubuntu
/etc/rc6.d - While system restarts