Ubuntu下添加开机启动脚本
来源:互联网 发布:抱枕公仔好的淘宝店 编辑:程序博客网 时间:2024/05/16 00:47
Ubuntu开机之后会执行/etc/rc.local文件中的脚本,所以我们可以直接在/etc/rc.local中添加启动脚本。
当然要添加到结束语句exit 0 的前面才行。
如:
$ sudo vi /etc/rc.local
然后在 exit 0 前面添加脚本代码或脚本的位置。
如果要添加为开机启动执行的脚本文件,可先将脚本复制或者软连接到/etc/init.d/目录下,
然后用命令
# update-rc.d xxx defaults NN
如update-rc.d test default 98
(NN为启动顺序),将脚本添加到初始化执行的队列中去。
注意如果脚本需要用到网络,则NN需设置一个比较大的数字,如98 。
1) 将你的启动脚本复制或软连接到 /etc/init.d目录下
以下假设你的脚本文件名为 test.sh
2) 设置脚本文件的权限
$ sudo chmod 755 /etc/init.d/test.sh
3) 执行如下命令将脚本放到启动脚本中去:
$ cd /etc/init.d
$ sudo update-rc.d test.sh defaults 95
注:其中数字95是脚本启动的顺序号,按照自己的需要相应修改即可。在你有多个启动脚本,而它们之间又有先后启动的依赖关系时就知道这个数字的具体作用了。
该命令的输出信息参考如下:
update-rc.d: warning: /etc/init.d/test missing LSB information
update-rc.d: see http://wiki.debian.org/LSBInitScripts
Adding system startup for /etc/init.d/test.sh ...
/etc/rc0.d/K95test.sh -> ../init.d/test.sh
/etc/rc1.d/K95test.sh -> ../init.d/test.sh
/etc/rc6.d/K95test.sh -> ../init.d/test.sh
/etc/rc2.d/S95test.sh -> ../init.d/test.sh
/etc/rc3.d/S95test.sh -> ../init.d/test.sh
/etc/rc4.d/S95test.sh -> ../init.d/test.sh
/etc/rc5.d/S95test.sh -> ../init.d/test.sh
卸载启动脚本的方法:
$ cd /etc/init.d
$ sudo update-rc.d -f test.sh remove
命令输出的信息参考如下:
Removing any system startup links for /etc/init.d/test ...
/etc/rc0.d/K95test.sh
/etc/rc1.d/K95test.sh
/etc/rc2.d/S95test.sh
/etc/rc3.d/S95test.sh
/etc/rc4.d/S95test.sh
/etc/rc5.d/S95test.sh
/etc/rc6.d/K95test.sh
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- 【转载】Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- Ubuntu下添加开机启动脚本
- NGUI的坑:UICamera类的EventType不要选择错了
- 腾讯产品培训生招聘寄语
- android 获取手机唯一识别码
- android控件属性大全
- Android系统架构概述
- Ubuntu下添加开机启动脚本
- [Unity3D]调用函数时出现NullReferenceException的一个可能原因
- asp.net mvc中分页--利用PagedList实现
- Your browse does not support frame!
- opencv中的mask参数
- 嵌入式程序员面试问题集锦
- USACO: Prime Palindromes
- Freemarker中的日期转换
- Oracle-创建用户和表空间