Debian添加开机启动项

Debian添加开机启动项Linux 系统设置开机启动有很多方法 网上也有许多详细教程 本文只关注用 update rc d 命令给 Debian 添加开机启动 例如 将 test sh 脚本添加到开机自启 1 将 test sh 脚本放到 etc init d 目录下 cptest sh etc init d cd etc init d chmod xtest sh2 设置开机自启 update rc dtest shdefaults 运行 update rc d 很可能会出现错误提示 ins

Linux系统设置开机启动有很多方法,网上也有许多详细教程。本文只关注用 update-rc.d 命令给 Debian 添加开机启动。

例如:将test.sh脚本添加到开机自启。

1.将 test.sh 脚本放到 /etc/init.d/ 目录下 cp test.sh /etc/init.d/ cd /etc/init.d/ chmod +x test.sh 
2.设置开机自启 update-rc.d test.sh defaults 运行 update-rc.d 很可能会出现错误提示: insserv: warning: script 'test.sh' missing LSB tags and overrides 
这是因为 test.sh 不符合 debian 开机自启文件的内容规范,debian 要求文件头部有启动信息。参考同目录下的 /etc/init.d/skeleton 文件头,把以下内容复制到 test.sh 再运行 update-rc.d test.sh defaults 。 #!/bin/sh  BEGIN INIT INFO # Provides: test # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Should-Start: $network # Should-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: test # Description: test  END INIT INFO 
3.删除开机启动 update-rc.d -f test.sh remove 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/231610.html原文链接:https://javaforall.net

(0)
上一篇 2025年12月2日 上午8:01
下一篇 2025年12月2日 上午8:22


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号