ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本

可以通过下列简单设置后,可以使rc.local重新发挥作用。

1、建立rc-local.service文件

sudo vi /etc/systemd/system/rc-local.service

2、将下列内容复制进rc-local.service文件

[Unit]

Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
 
[Install]
WantedBy=multi-user.target
 
3、创建文件rc.local
sudo vi /etc/rc.local
 
4、将下列内容复制进rc.local文件
#!/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.
echo "看到这行字,说明添加自启动脚本成功。" /usr/local/test.log
exit 0
 
5、给rc.local加上权限
sudo chmod +x /etc/rc.local
 
6、启用服务
sudo systemctl enable rc-local
 
7、启动服务并检查状态
sudo systemctl start rc-local.service

sudo systemctl status rc-local.service
 
8、重启并检查test.log文件
cat /usr/local/test.log
 
如果能看到内容,说明设置成功,你就可以通过编辑rc.local文件来设置启动脚本了

ubuntu高版本如何设置开机启动脚本的更多相关文章

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

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

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

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

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

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

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

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

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

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

  6. ubuntu设置开机启动脚本

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

  7. Fedora 21 设置开机启动脚本

    sudo touch /etc/rc.d/rc.localsudo vim /etc/rc.d/rc.local 在/etc/rc.d/rc.local文件中写入, 然后使用:wq命令 保存并退出. ...

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

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

  9. ubuntu 18.04 - server版 开机启动脚本

    ubuntu 18.04 不再使用 inited 管理系统,改用 systemd systemd 默认读取 /etc/systemd/system 下的文件,该目录下的文件会链接/lib/system ...

随机推荐

  1. MySQL 过滤数据(WHERE子句)

    WHERE子句操作符 从表products中检索prod_name,prod_price列,返回prod_price=2.5的行 mysql> SELECT  prod_name, prod_p ...

  2. 怎么用fiddler抓APP的包

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/liujingqiu/article/details/79387909Fiddler安装 此处略.我们 ...

  3. cpu怎么实现运算的

      这么好玩的问题,没人回答说不过去.不懂电子元件的码农我要强答一发了.太学术的我不会,你们也听不懂.所以臭不要脸非常不严谨地科普一记.说错不许打我.另外关于这个问题,推荐<编码 (豆瓣)> ...

  4. 转---CentOS安装Oracle数据库详细介绍及常见问题汇总

    一.安装前准备 1.软件硬件要求 操作系统:CentOS 6.4(32bit)Oracle数据库版本:Oracle 10g(10201_database_linux32.zip)最小内存:1G(检查命 ...

  5. svn hooks post-commit钩子自动部署

    #!/bin/sh #修改为服务编码 export LANG=zh_CN.utf- #Set variable REPOS="$1" REV="$2" SVN= ...

  6. Python单元测试框架之pytest 3 -- fixtures

    From: https://www.cnblogs.com/fnng/p/4769020.html Python单元测试框架之pytest -- fixtures 2015-08-29 13:05 b ...

  7. JIRA 资源

    https://www.**.com/article/2015/8/7/22532.html e_v_g_e_t JIRA使用教程:在Windows上安装JIRAJIRA使用教程:在Linux上安装J ...

  8. Memcached 集群架构方面的问题 [z]

    集群架构方面的问题       memcached是怎么工作的? Memcached的神奇来自两阶段哈希(two-stage hash).Memcached就像一个巨大的.存储了很多<key,v ...

  9. 学习笔记之Supervised Learning with scikit-learn | DataCamp

    Supervised Learning with scikit-learn | DataCamp https://www.datacamp.com/courses/supervised-learnin ...

  10. imageLoader之介绍

    相信大家在学习以及实际开发中基本都会与网络数据打交道,而这其中一个非常影响用户体验的就是图片的缓存了,若是没有弄好图片缓存,用户体验会大大下降,总会出现卡顿情况,而这个问题尤其容易出现在ListVie ...