1. ubuntu18.04 默认不带有rc.local的配置

  1. # 1.创建软连接 -- root用户
  2. ln -sf /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
  3. # 添加一句命令行 -- root用户
  4. cat >>/etc/systemd/system/rc-local.service<<EOF
  5. [Install]
  6. WantedBy=multi-user.target
  7. Alias=rc-local.service
  8. EOF
  9. # 2.创建rc.local文件并 赋权
  10. touch /etc/rc.local && chmod 755 /etc/rc.local
  11. # 3.导入必要的语句
  12. cat >>/etc/rc.local<<EOF
  13. #!/bin/bash
  14. /bin/bash /etc/rsync/rsync.init.sh > /dev/null 2>&1 &
  15. /usr/local/qif/nginx/sbin/nginx -c /usr/local/qif/nginx/conf/nginx.conf
  16. /bin/bash /home/qif/stream_new/start.sh daemon > /dev/null
  17. exit 0
  18. EOF
  1. # 自启动脚本
  2. #!/bin/bash -e
  3. /usr/local/qif/nginx/sbin/nginx -c /usr/local/qif/nginx/conf/nginx.conf
  4. cd /home/qif/stream_new && ./daemon.sh > /dev/null
  5. exit 0