ubuntu-18.04 设置开机启动脚本-亲测有效
Ubuntu 设置 启动 脚本 有效 开机 亲测 18.04
2023-09-11 14:17:11 时间
ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.local重新发挥作用。
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下允许Root用户的操作 (图形界面登录、su切换……)
- ubuntu设置服务开机启动
- Ubuntu等保三级检查命令
- Ubuntu设置和查看环境变量
- Ubuntu设置gcc/g++/make输出颜色高亮
- ubuntu中使用virt-manager图形化新建虚拟机
- ubuntu 22.04设置字体为Garuda(mac字体Lucida Grande的开源替代)
- ubuntu deepin等debian系Linux发行版安装docker-ce命令
- linux ubuntu/deepin与Windows时间不同步解决办法(双系统)
- VMWare软件linux虚拟机安装Ubuntu&BIOS设置
- Ubuntu 下设置不锁屏(不休眠)
- 【ubuntu】解决虚拟机Ubuntu连接不了网络(亲测)
- ubuntu上设置pycharm快捷方式详细贴图步骤
- ubuntu没有网卡驱动
- ubuntu设置pycharm
- Linux(ubuntu) 添加快捷方式到桌面——qtcreator创建快捷方式
- ubuntu 18.04取消自动锁屏以及设置键盘快捷锁屏
- ubuntu设置开机启动图形应用程序,替换默认图形桌面
- ubuntu中安装好anaconda之后,系统终端界面前面出现(base)字样
- Ubuntu 14.04 设置Android开发环境
- ubuntu opencv c++ 读取摄像头
- 嵌入式linux开发,Ubuntu下安装、使用cmake及图形界面cmake-gui,及cmake配置交叉编译工具
- Ubuntu 18.04.5 LTS安装zabbix-agent5.0报错依赖: libcurl3 (>= 7.16.2) 但是它将不会被安装-完美解决
- Ubuntu 18.04 分辨率设置
- ubuntu 16.04 tightvncserver VNC 安装配置,安装xrdp,x11vnc、Ubuntu 18.04
- Ubuntu设置静态IP/网关(十一)
- ubuntu 系统设置bugzilla制
- Ubuntu下VS Code 字体设置 + 标签匹配、括号匹配插件
- ubuntu 设置IP,设置网关
- kolla-ansible在ubuntu部署openstack