rc.local脚本

rc.local脚本是一个ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令。该脚本位于/etc/路径下,需要root权限才能修改。

该脚本具体格式如下:

  1. #!/bin/sh -e
  2. #
  3. # rc.local
  4. #
  5. # This script is executed at the end of each multiuser runlevel.
  6. # Make sure that the script will "exit 0" on success or any other
  7. # value on error.
  8. #
  9. # In order to enable or disable this script just change the execution
  10. # bits.
  11. #
  12. # By default this script does nothing.
  13.  
  14. exit 0

注意: 一定要将命令添加在 exit 0之前

如何给ubuntu添加一个开机启动脚本

1,新建个脚本文件new_service.sh

  1. #!/bin/bash
  2. # command content
  3.  
  4. exit 0

2,设置权限

  1. sudo chmod 755 new_service.sh

3,把脚本放置到启动目录下

  1. sudo mv new_service.sh /etc/init.d/

4,将脚本添加到启动脚本

执行如下指令,在这里90表明一个优先级,越高表示执行的越晚

  1. cd /etc/init.d/
  2. sudo update-rc.d new_service.sh defaults 90

移除Ubuntu开机脚本

  1. sudo update-rc.d -f new_service.sh remove

Ubuntu 14.04设置开机启动脚本的方法的更多相关文章

  1. Ubuntu 16.04设置开机启动脚本的方法

    需求:公司卡片机容量太小,只有100G,由于使用的人比较的多,开机使用后有时候就会出现磁盘空间占满数据写不进去的情况,影响工作进度,而且每次使用完都得关掉卡片机,所以就有必要写个清理磁盘的脚本,当卡片 ...

  2. Ubuntu 18.04 设置开机启动脚本 rc.local systemd

    ubuntu18.04不再使用initd管理系统,改用systemd. ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.l ...

  3. ubuntu-18.04 设置开机启动脚本

    ubuntu-18.04 设置开机启动脚本 参阅下列链接 https://askubuntu.com/questions/886620/how-can-i-execute-command-on-sta ...

  4. ubuntu-18.04 设置开机启动脚本-亲测有效

    ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.local重新发挥作用. 2.将下列内容复制进rc-local.servi ...

  5. Ubuntu14.04设置开机启动脚本(转)

    原文:https://www.magentonotes.com/ubuntu-config-autostart-shell-script.html 方法一:将脚本添加到文件/etc/rc.local ...

  6. ubuntu-server-18.04 设置开机启动脚本

    ubuntu-16.10 开始不再使用initd管理系统,改用systemd systemd is now used for user sessions. System sessions had al ...

  7. Ubuntu-18.04设置开机启动脚本

    参考:https://www.cnblogs.com/defifind/p/9285456.html    http://www.cnblogs.com/airdot/p/9688530.html s ...

  8. Ubuntu 16.04设置开机启动应用程序

    在终端通过以下命令进行设置,Dash已经搜索不到Startup了: gnome-session-properties 或者直接在Dash中搜索:gnome-session

  9. ubuntu高版本如何设置开机启动脚本

    ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本 可以通过下列简单设置后,可以使rc.local重新发挥作用. 1.建立rc-local.service文件 ...

随机推荐

  1. Word转换为markdown

    Word转换为markdown 首先你的电脑要有office word 1   安装pandoc https://github.com/jgm/pandoc/releases,可以找到最新的pando ...

  2. pycharm进行调试[转载]

    转自:https://blog.csdn.net/william_hehe/article/details/80898031 1.首先设置断点. 2.Step into(F7):进入 若函数A内存在子 ...

  3. win10 java环境变量的正确配置

    变量名:[JAVA_HOME]变量值:[D:\Program Files\Java\jdk1.8.0_92][jdk安装路径]变量名:[Path]变量值:[;%JAVA_HOME%\bin;%JAVA ...

  4. python -- 解决If using all scalar values, you must pass an index问题

    [问题描述] 在将dict转为DataFrame时会报错:If using all scalar values, you must pass an index 例如: summary = pd.Dat ...

  5. mysql参数配置文件

    (1)参数配置文件中的内容以键值对形式存在. (2)如何查看键值对?show variables like '%name%';或者查看information_schema库下的global_varia ...

  6. font-awesome图标

  7. Python 成对处理数据 zip()

    当你想成对处理数据的时候zip() 函数是很有用的.比如,假设你头列表和一个值列表,就像下面这样: headers = ['name', 'shares', 'price'] values = ['A ...

  8. linux常用命令:rpm 命令

    rpm是一个功能十分强大的软件包管理系统. 1.命令格式: rpm  [参数]  [包名] 2.命令功能: 使得在Linux下安装.升级和删除软件包的工作变得容易,并且具有查询.验证软件包的功能.与图 ...

  9. java多线程----拒绝策略

    本章介绍线程池的拒绝策略.内容包括:拒绝策略介绍拒绝策略对比和示例 转载请注明出处:http://www.cnblogs.com/skywang12345/p/3512947.html 拒绝策略介绍 ...

  10. python如何序列化json数据

    使用json模块提供的loads方法和dumps方法,可以很方便的载入和读取json数据格式.而在具体实际应用中,我们使用python数据格式是 string.list 或dict等,这类格式如何直接 ...