Ubuntu 18.04 uses rc.local to set up the program to start automatically at boot (but there is no daemon function)

1. Modify rc-local.service

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

    add content

[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. Activate service

sudo systemctl enable rc-local.service

3. Modify the rc.local file, add it if it does not exist, and grant permissions

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

   add content

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

Related information -------(10 messages) Ubuntu setup program auto-starts at boot_BAIFOL's blog-CSDN blog_ubuntu auto-starts at boot

Guess you like

Origin blog.csdn.net/qq_42314865/article/details/126861960