Centos6.1 , Centos6.5 开机启动

楼主2个服务器,一个是centos6.5  一个是6.1

   

    1.cat /etc/issue 查看版本,。

    centos 6.1  方法一,方法二都可以开机启动 (自定义的脚本)

    centos6.5  我这里测试只能方法二启动成功,或许是我系统未知问题导致(自定义的脚本)

    开机启动 2个方式:

    方法一 chkconfig 管理:

          第一步:  vi  /etc/init.d/test

          第二步:  

                        #! /bin/bash

                        # chkconfig:3 88 88

                         nohup python3 /root/xx.py > /dev/null 2>&1 &

                       保存

            
第三步: chmod +x /etc/init.d/test 

                          #  添加到chkconfig,开机自启动

                           chkconfig --add test

                   具体chkconfig 命令查看: https://www.runoob.com/linux/linux-comm-chkconfig.html

  方法二  将服务启动命令加入到/etc/rc.d/rc.local中:

     #!/bin/sh

     #
     # This script will be executed *after* all the other init scripts.
     # You can put your own initialization stuff in here if you don't
     # want to do the full Sys V style init stuff.

     touch /var/lock/subsys/local

     nohup python3 /root/xx.py  > /dev/null 2>&1 &
   

  需要将完整路径写入,否则不起作用  (有软连接的不算)

           

原文地址:https://www.cnblogs.com/pythonSF/p/14488499.html