我目前面临一个奇怪的问题。 我在 alix.2d2 上的 linux voyage 下使用 debian squeeze,并尝试使用 init.d 在启动时启动自制脚本。
为此,我编写了一个简单的脚本,将其放入/etc/init.d/(/etc/init.d/linknx) 并使用 update-rc.d 配置启动。
update-rc.d linknx start 191 12345
在重新启动之前,我正在使用以下命令测试脚本:
service linknx start
效果很好。 当系统重新启动时,脚本不会启动。我正在尝试使用 update-rc.d 更改启动配置
update-rc.d linknx defaults
同样的问题。
之后,我将清理启动配置,并在/etc/rc.local 中添加两行。
> sh -c "logger -p local0.notice [LAUNCHTEST] "rc.local invoking"
> service linknx start
第一行通过,但第二行失败。
有人能找出问题所在吗?
感谢您的帮助! 问候
<小时/>脚本:
#!/bin/sh -e1
### BEGIN INIT INFO
# Provides: linknx
# Required-Start: $local_fs $remote_fs $network $syslog $nocatsplash
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: Start/stop linknx daemon
# Description: Simnet linknx daemond starter.
### END INIT INFO
now=$(date +"%F %k:%M:%S")
port=3671
ip=192.168.2.10
LD_LIBRARY_PATH=/usr/local/lib
knx_config_file=/etc/linknx.xml
knx_write_file=/etc/linknx.xml
log_tag="[LINKNX]"
log_level="-p local0.notice"
case "$1" in
start)
logger $log_level -t $log_tag -s "Starting linknx and eibd ..."
ldconfig -l
eibd -d -D -S -T -i ipt:$ip:$port
linknx -d --config=$knx_config_file --write=$knx_write_file
logger $log_level -t $log_tag -s "Done\n"
;;
stop)
;;
reload|restart|force-reload)
;;
test)
logger $log_level -t $log_tag -s "[$now] - [TEST] - This is a simple test to check behavior of the program ..."
;;
*)
logger $log_level -t $log_tag -s "[$now] - [FATAL] - Unknow command, only available are start|stop|restart|reload|force-reload"
;;
esac
exit 0
最佳答案
你应该使用
insserv linknx
不是
update-rc.d linknx defaults
从 Debian 6.0 (Squeeze) 开始,update-rc.d 已被 insserv 取代(请参阅 here )。为什么?因为6.0引入了new boot process ,您已为其准备好 header (脚本顶部的 INIT INFO 部分)。
关于linux - 自动启动服务失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10138319/