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

rc.local脚本

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

该脚本具体格式如下:

#!/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.
#/bin/sh /home/saneri/new_service.sh #脚本范例 exit 0

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

方法2:

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

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

#!/bin/bash
# command content
# ..................................
exit 0

2,设置权限

sudo chmod 755 new_service.sh

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

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

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

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

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

移除Ubuntu开机脚本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  9. Ubuntu 16.04设置开机关机时显示命令详细信息不显示进度条Logo

    1.编辑grub文件 sudo gedit /etc/default/grub 把 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 改成 GRU ...

随机推荐

  1. BeanPostProcessor出现init方法无法被调用Invocation of init method failed

    是因为 返回了null,要返回object即可,arg0是bean对象本身,arg1是bean名字,即bean的id

  2. Centos服务器端口无法访问

    使用GPRS A6 模块进行TCP连接的时候,一度认为A6模块坏掉了 最终只是服务器端口都被防火墙堵住了 使用之前一直用的  service iptables stop  找不到iptables 原来 ...

  3. 关于不执行整个大项目而是执行其中一部分独立文件夹的时候的python运行方法

    这是项目的整个目录,如果是点击右键运行ic_kw_ks_func.py的话是会报ic_kw_ks_func.py里面import的那些其他路径下的类和函数找不到.而我们发现有个-m的python命令能 ...

  4. GMA Round 1 三视图

    传送门 三视图 该几何体如图所示,是一个边长为$2\sqrt{3}$的正四面体,高是$h=2\sqrt{2}$,内切球半径是$r=\frac{h}{4}=\frac{\sqrt{2}}{2}$,则体积 ...

  5. poj3614 Sunscreen(贪心+STL)

    https://vjudge.net/problem/POJ-3614 如果这不是优先队列专题里的,我可能不一定能想到这么做. 结构体命名得有点不好,解题中看着Edge这个不恰当的命名,思路老是断掉. ...

  6. Your project is not referencing the ".NETPortable,Version=v4.5,Profile=Profile259" framework. Add a reference to ".NETPortable,Version=v4.5,Profile=Profile259" in the "frameworks" section of your proj

    i want to add nuget packages to my portable class library project , then i add a project.json to my ...

  7. Android Studio提示 Connection reset

    解决步骤: 1:Android studio开发工具:File -> Invalidate caches / Restart:选择Invalidate and Restart关闭 Android ...

  8. CoordinatorLayout使用详解: 打造折叠悬浮效果

    1.简介 CoordinatorLayout遵循Material 风格,包含在 support Library中,结合AppbarLayout, CollapsingToolbarLayout等 可 ...

  9. docker中的数据库

      注:自从开始使用docker,部署方面的事情就简单多了.使用docker构建的数据库容器不用直接安装,开启后就可以使用,也比以前方便很多.下面将一些要点记录下来. 下面的例子使用以下环境: - 系 ...

  10. Spark(四十五):Schema Registry

    很多时候在流数据处理时,我们会将avro格式的数据写入到kafka的topic,但是avro写入到kafka的时候,数据有可能会与版本升级,也就是schema发生变化,此时如果消费端,不知道哪些数据的 ...