源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Ubuntu 14.04设置开机启动脚本的方法

  • 时间:2022-12-25 23:19 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Ubuntu 14.04设置开机启动脚本的方法
[b]rc.local脚本[/b] rc.local脚本是一个ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令。该脚本位于/etc/路径下,需要root权限才能修改。 [b]该脚本具体格式如下:[/b]
#!/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
[b]注意: [/b]一定要将命令添加在 exit 0之前 [b]如何给ubuntu添加一个开机启动脚本[/b] [b]1,新建个脚本文件new_service.sh[/b]
#!/bin/bash
# command content
 
exit 0
[b]2,设置权限[/b]
sudo chmod 755 new_service.sh
[b]3,把脚本放置到启动目录下[/b]
sudo mv new_service.sh /etc/init.d/
[b]4,将脚本添加到启动脚本[/b] 执行如下指令,在这里90表明一个优先级,越高表示执行的越晚
cd /etc/init.d/
sudo update-rc.d new_service.sh defaults 90
[b]移除Ubuntu开机脚本[/b]
sudo update-rc.d -f new_service.sh remove
[b]总结[/b] 以上就是这篇文章的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部