linux系统/etc/init.d目录下的开机自启脚本

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.重启验证

结束。

原文地址:https://www.cnblogs.com/chinasoft/p/14733336.html