在設(shè)置frp的時(shí)候,需要添加到開機(jī)自啟動(dòng)項(xiàng)目中。
不過ubuntu-18.04不能像ubuntu14一樣通過編輯rc.local來設(shè)置開機(jī)啟動(dòng)腳本,通過下列簡單設(shè)置后倚舀,可以使rc.local重新發(fā)揮作用叹哭。
- 建立rc-local.service文件
sudo vi /etc/systemd/system/rc-local .service
- 將下列內(nèi)容復(fù)制進(jìn)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
- 創(chuàng)建文件rc.local
sudo vi /etc/rc.local
- 將下列內(nèi)容復(fù)制進(jìn)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 "看到這行字忍宋,說明添加自啟動(dòng)腳本成功。" > /usr/local/test.log
exit 0
-
給rc.local加上權(quán)限,啟用服務(wù)
sudo chmod +x /etc/rc.local sudo systemctl enable rc-local
啟動(dòng)服務(wù)并檢查狀態(tài)
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service
- 重啟并檢查test.log文件
cat /usr/local/test.log