1.复制或剪切文件到/etc/rc.d/init.d 目录下

    1. mv /opt/npc/start.sh /etc/rc.d/init.d

    2.增加脚本的可执行权限

    1. chmod+x /etc/rc.d/init.d/start.sh

    3.添加脚本到开机自动启动项目中

    1. cd/etc/rc.d/init.d
    2. chkconfig --add start.sh
    3. chkconfig start.sh on

    注意如果报错 :::danger service xxxx does not support chkconfig :::

    在脚本开头出添加#chkconfig#description。服务不支持 chkconfig另外还有一个非常重要的原因
    就是可执行权限。

    1. #!/bin/bash
    2. #chkconfig: - 85 15
    3. #description: 内网穿透
    4. nohup ./npc -server=110.42.192.20:8024 -vkey=n2tj612o01apsvtp >nohup.out 2>&1 &