This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
该脚本现在应该在启动时启动。请注意,此方法也适用于硬链接和符号链接 (
ln
)。此时,启动过程中的 PATH 尚未设置,因此自始至终使用绝对路径至关重要。 但是,正如 Steve HHH 的评论中所指出的,明确声明 update-rc.d 命令的完整文件路径 (
/etc/init.d/filename
)在大多数 Linux 版本中无效。根据 update-rc.d 的手册页,第二个参数是位于/etc/init.d/*
中的脚本。另外,正如评论(Charles Brandt)所指出的,
/filename
必须是 init 样式脚本。还提供了一个很好的模板 - System V init 脚本模板。正如评论(Russell Yan)所指出的,这仅适用于 update-rc.d 的默认模式。
根据update-rc.d的手册,它可以运行在两种模式下:“使用legacy模式的机器将有一个文件
/etc/init.d/.legacy-bootordering
”,在在这种情况下,您必须通过命令行参数传递序列和运行级别配置。上述示例的等效参数集是
sudo update-rc.d filename start 20 2 3 4 5 。停止 20 0 1 6 。
The script should now start on boot. Note that this method also works with both hard links and symbolic links (
ln
).At this point in the boot process PATH isn't set yet, so it is critical that absolute paths are used throughout. But, as pointed out in the comments by Steve HHH, explicitly declaring the full file path (
/etc/init.d/filename
) for the update-rc.d command is not valid in most versions of Linux. Per the manpage for update-rc.d, the second parameter is a script located in/etc/init.d/*
.Also as pointed out in the comments (by Charles Brandt),
/filename
must be an init style script. A good template was also provided - System V init script template.As pointed out in the comments (by Russell Yan), this works only on default mode of update-rc.d.
According to the manual of update-rc.d, it can run on two modes: "the machines using the legacy mode will have a file
/etc/init.d/.legacy-bootordering
", in which case you have to pass sequence and runlevel configuration through command line arguments.The equivalent argument set for the above example is
sudo update-rc.d filename start 20 2 3 4 5 . stop 20 0 1 6 .