https://www.cnblogs.com/liusingbon/p/13037735.html
1.復制或軟連接腳本到/etc/init.d/目錄下
2.腳本內容如下,加粗內容是模板性注釋,不能更改。
$cat /etc/init.d/test.sh
#!/bin/bash
### BEGIN INIT INFO
# Provides: test.sh //test.sh是自己創建的腳本名稱
# Required-Start: $local_fs $network $remote_fs $syslog
# Required-Stop: $local_fs $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the test.sh daemon //test.sh是自己創建的腳本名稱
# Description: starts test.sh using start-stop-daemon //test.sh是自己創建的腳本名稱
### END INIT INFO
sudo cp /media/share/frp_0.27.0_linux_amd64.tar.gz /opt/ //開機后需要執行的命令
3.賦權限給腳本文件
$sudo chmod 755 /etc/init.d/test.sh
4.加入開機啟動
$sudo update-rc.d /etc/init.d/test.sh defaults 90
5.重啟驗證
結束。