Ubuntu 14.04 设置开机启动脚本
106
0
/etc/rc.local 脚本
/etc/rc.local 脚本是一个Ubuntu开机后会自动执行的脚本,可以在该脚本内添加命令行指令。
该脚本位于/etc/路径下,需要root权限才能修改。
该脚本具体格式如下:
vim /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. exit 0
注意: 一定要将命令添加在 exit 0之前,exit 0 之后的脚本不会执行,但可用做注释哈
Ubuntu 添加一个开机启动脚本
1、新建个脚本文件new_service.sh
#!/bin/bash # mimvp.com auto start exit 0
2、设置权限
sudo
chmod
755 new_service.sh
3、把脚本放置到启动目录下
sudo
mv
new_service.sh
/etc/init
.d/
4、将脚本添加到启动脚本
cd
/etc/init
.d/
sudo
update-rc.d new_service.sh defaults 90
5、移除Ubuntu开机脚本
sudo
update-rc.d -f new_service.sh remove
版权所有: 本文为米扑博客原创,或修订后发表,最后更新于 2018-01-12 19:42:00