ubuntu 18.04 使用rc.local 设置程序开机自启动(但无守护进程的功能)

1. 修改rc-local.service

sudo vim /etc/systemd/system/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

2.激活服务

sudo systemctl enable rc-local.service

3.修改rc.local文件,若没有则添加,并赋予权限

sudo touch /etc/rc.local
sudo chmod 777 /etc/rc.local
gedit /etc/rc.local

   增加内容

#!/bin/sh -e
#开机自启程序的运行命令,注意:不会自动结束的程序,必须加 & 表示在后台运行
/home/work/Documents/build-SDK-Desktop-Debug/SDK &
exit 0

相关资料-------(10条消息) Ubuntu设置程序的开机自启动_BAIFOL的博客-CSDN博客_ubuntu 开机自启动

猜你喜欢

转载自blog.csdn.net/qq_42314865/article/details/126861960
今日推荐