rc.local 和rc-local.service
创建rc-loca.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
创建rc.local
sudo vim /etc/rc.local
#!/bin/sh
echo "=== Run Validator ==="
nohup `sleep 10 && /opt/validator` &
exit 0
非阻塞式的开启了后台程序validator,并在开启之前先休眠10秒
测试
sudo systemctl start rc-local.service
sudo systemctl stop rc-local.service