ubuntu14.04 设置开机自启动脚本
2017-04-07 20:53
471 查看
方法一, 编辑rc.local脚本
ubuntu开机之后会执行/etc/rc.local文件中的脚本。所以可以直接在/etc/rc.local中添加启动脚本。脚本要添加到 exit 0 之前。
以下是rc.local 初始状态,在exit 0之前添加需要执行的操作即可。
方法二, 添加一个ubuntu的开机启动服务
分为以下几个步骤:
1)新建一个脚本文件 new_services.sh
2)将脚本放置到启动目录下
3)设置权限
4)将脚本添加到启动脚本
这里90表明一个优先级,越高表示执行的越晚。
移除ubuntu开机脚本
ubuntu开机之后会执行/etc/rc.local文件中的脚本。所以可以直接在/etc/rc.local中添加启动脚本。脚本要添加到 exit 0 之前。
以下是rc.local 初始状态,在exit 0之前添加需要执行的操作即可。
#!/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
方法二, 添加一个ubuntu的开机启动服务
分为以下几个步骤:
1)新建一个脚本文件 new_services.sh
#!/bin/bash # command content exit 0
2)将脚本放置到启动目录下
sudo mv new_services.sh /etc/init.d/
3)设置权限
sudo chmod 755 new_services.sh
4)将脚本添加到启动脚本
cd /etc/init.d/ sudo update-rc.d new_serviecs.sh defaults 90
这里90表明一个优先级,越高表示执行的越晚。
移除ubuntu开机脚本
sudo update-rc.d -f new_services.sh remove
相关文章推荐
- Ubuntu14.04设置开机自启动脚本
- 【ubuntu】 ubuntu14.04 设置开机自启动脚本
- Ubuntu 14.04 脚本开机自启动
- Ubuntu14.04设置开机启动脚本
- Ubuntu 14.04 脚本开机自启动
- Ubuntu 14.04设置开机启动脚本的方法
- ubuntu下设置开机自启动项
- ubuntu下设置开机自启动项
- Ubuntu 创建开机自启动脚本的方法
- linux_设置开机自启动程序脚本
- ubuntu 开机加载静态路由设置(开机脚本)
- Windows设置开机自启动bat脚本
- ubuntu下设置开机自启动项
- ubuntu下设置程序开机自启动的几种方法 分享
- ubuntu下设置开机自启动项
- 将命令添加到shell脚本中然后设置开机自启动
- ubuntu下设置开机自启动项
- Ubuntu 创建开机自启动脚本的方法
- Ubuntu 创建开机自启动脚本的方法
- Ubuntu 设置svn开机自启动