Ubuntu20.04 开机启动程序

1.编辑/etc/systemd/system/rc-local.service文件末尾增加以下内容

[Install]
WantedBy=multi-user.target
Alias=rc-local.service

2. 编辑/etc/rc.local文件,如果不存在则新建
示例:

#!/bin/sh -e

sudo /home/root/scripts/checkrobot.sh >/dev/null 2>&1 &

exit 0

3. 启动服务

sudo systemctl enable rc-local
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service