我有一个简单的/etc/init.d/myscript
启动脚本Debian squeeze
,只需记录到文件中:
echo "starting init.d script" >> /opt/aaa/starting.log
我完成了注册脚本的所有操作:
sudo chmod +x myscript
sudo chown root:root myscript
sudo update-rc.d myscript defaults
sudo update-rc.d myscript enable
但无法获取/opt/aaa/starting.log
文件中的记录。
如何解决该问题?
答案1
您缺少强制性标题,这就是 update-rc.d 无法设置在系统启动时启动的脚本的原因。
来自 /etc/init.d/README
All init.d scripts are expected to have a LSB style header documenting
dependencies and default runlevel settings. The header look like this
(not all fields are required):
### BEGIN INIT INFO
# Provides: skeleton
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $portmap
# Should-Stop: $portmap
# X-Start-Before: nis
# X-Stop-After: nis
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
More information on the format is available from insserv(8). This
information is used to dynamicaly assign sequence numbers to the
boot scripts and to run the scripts in parallel during the boot.
See also /usr/share/doc/insserv/README.Debian.
首先尝试理解一个有效的初始化脚本(比如 ssh),然后尝试适应您的用法。