【发布时间】:2016-04-03 21:56:40
【问题描述】:
我需要在系统启动 (Linux-Debian) 后通过 .sh 脚本启动我的 Wildfly AS。所以我创建了自己的脚本,应该在 init.d 中完成:
#! /bin/sh
# /etc/init.d/starter
case "$1" in
start)
echo "Starting"
nohup /home/xxx/wildfly-9.0.1.Final/bin/standalone.sh &
;;
stop)
echo "Stopping"
/home/xxx/wildfly-9.0.1.Final/bin/jboss-cli.sh --connect command=:shutdown
;;
*)
echo "Usage: /etc/init.d/starter {start|stop}"
exit 1
;;
esac
exit 0
如果我自己使用它有效:/etc/init.d/starter start。
然后我使用命令创建符号链接:update-rc.d starter defaults。符号链接按预期创建,但是在reboot 命令之后脚本没有执行。
有人知道是什么阻止了我的脚本在启动后执行吗?感谢您的所有建议。
【问题讨论】:
-
哪个版本的 Debian? Debian v6 或更高版本将 update-rc.d 替换为 inserve...参见 Debian Wiki [How to add a service when using dependency-based booting] (wiki.debian.org/LSBInitScripts/DependencyBasedBoot)
-
@agc 感谢您的回复。我正在运行 8.3。在 man insserv 中,我读到:“不建议直接执行 insserv,除非您确切知道自己在做什么,否则可能会使您的引导系统无法运行。update-rc.d 是用于管理初始化脚本的推荐界面。”所以这不是问题。
-
抱歉——我错过了。嗯,权限,也许。这个输出有什么不寻常的地方: find /etc/rc?.d/ -name 'starter' -exec ls -l '{}' \; ; ls -l /etc/init.d/starter 通常每个链接都应该由 *root 拥有,并且文件模式为 'lrwxrwxrwx (0777)',文件本身的模式为 '-rwxrwxr-x (第0775章