我有一个debian最小安装,我只想在启动时启动一个自定义脚本。
我把一个chmod 700 ,并创build符号链接到S20myscript到:
/etc/rc2.d /etc/rc3.d /etc/rc4.d /etc/rc5.d
但是,脚本在启动时根本不会启动。
当我用update-rc.d (或者insserv …)来使用这个脚本的时候,它可以工作。
我不明白,我是否被迫使用这个命令?
(和不,我不想使用/etc/rc.local )。
尝试删除rc*.d目录中的所有符号链接。
然后,尝试运行:
update-rc.d -n myscript enable
其中-n意思not-really
这将列出insserv应该做什么:制作符号链接并生成一些.depend.*文件
看看init.d/.depend.boot , init.d/.depend.start和init.d/.depend.stop :也许你需要更新这些文件? 如果您决定手动更改它们(但是update-rc.d什么问题?)要特别注意,进一步调用update-rc.d不会update-rc.d您的编辑。
请参阅man startpar和man insserv ,以获取有关这些.depend.*文件用法的知识。
我最后的build议是:使用update-rc.d 🙂
将它添加到/etc/rc.local有什么问题? 这是最简单的方法:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing.