Ubuntu下自定义开机启动脚本 |
您所在的位置:网站首页 › ubuntu添加自启动脚本 › Ubuntu下自定义开机启动脚本 |
进入/etc/init.d目录,使用vi命令创建脚本文件test.sh [email protected]:/home# cd /etc/init.d/
[email protected]:/etc/init.d# vi test.sh
编写test.sh内容 #!/bin/bash
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
...此处添加自己的脚本代码
注:### BEGIN INIIT INTFO 和 ### END INIT INFO 之间的内容必须写,否则会报错.......missing LSB tags and overrideshttps://wiki.debian.org/LSBInitScripts 修改脚本的可执行权限 [email protected]:/etc/init.d# chomd +x test.sh将脚本添加到开机脚本 [email protected]:/etc/init.d# update-rc.d test.sh defaults 90注:前面四步已完成开机启动自定义脚本功能 如果需要移除开机脚本,使用以下代码 [email protected]:/etc/init.d# update-rc.d -f test.sh remove
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |