脚本设定开机自启动

脚本设定开机自启动
方法一:
1,在某个目录下创建脚本:例如:/root/hello/wei.sh
 (注意:脚本中必须加入: #!/bin/bash
#chkconfig:2345 10 90
#description:resind
2,cp /root/hello/wei.sh  /etc/init.d/wei.sh
   (注意:也可以直接在 /etc/init.d下,直接创建wei.sh脚本)
3. 给脚本执行权限:chmod +x /etc/init.d/wei.sh
4. 加入开机启动,进/etc/init.d/目录下:chkconfig  --add  wei.sh
                                  chkconfig   wei.sh   on
       查看wei.sh开机自启动情况: chkconfig   --list   wei.sh
(注意非加入自启动而是手动启动这样:/etc/init.d/wei.sh  start)
 
方法二:
1.写一脚本,Wei.sh 放在、etc/init.d、下面。即/etc/init.d/wei.sh
2,加权限 chmod  +x  /etc/init.d/wei.sh
3.写入到/etc/rc.local开机自启动文件里:
   echo “/etc/init.d/wei.sh”>> /etc/rc.local
4  chmod  +x  /etc/rc.local

原文地址:https://www.cnblogs.com/creater-wei/p/9998704.html