美文网首页
centos7 添加开机自启动sh脚本

centos7 添加开机自启动sh脚本

作者: liunewshine | 来源:发表于2019-09-29 17:18 被阅读0次

    1.添加开机自启脚本

    脚本路径和内容试自己情况而定,下面是示例sh内容

    #!/bin/bash
    nohup /webapps/frp/frps -c /webapps/frp/frps.ini &
    

    2.赋予脚本可执行权限

    chmod +x /webapps/shell/autostart.sh
    

    3.打开/etc/rc.d/rc.local文件,在末尾增加如下内容

    echo "/webapps/shell/autostart.sh >/webapps/shell/log.log 2>&1" >> /etc/rc.d/rc.local
    

    或者使用vi/vim编辑器,在末尾追加

    vi /etc/rc.d/rc.local
    

    4.赋予/etc/rc.d/rc.local的执行权限

    在centos7中,/etc/rc.d/rc.local的权限被降低了,所以需要执行如下命令赋予其可执行权限

    chmod +x /etc/rc.d/rc.local
    

    相关文章

      网友评论

          本文标题:centos7 添加开机自启动sh脚本

          本文链接:https://www.haomeiwen.com/subject/fsfqpctx.html