• 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 &
       

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

               

  • 相关阅读:
    subprocess 子进程模块
    3.5 魔法方法
    ThinkPHP中,display和assign用法详解
    linux常用指令
    退出当前Mysql使用的db_name 的方式
    PHP中GD库是做什么用的? PHP GD库介绍11111111
    include跟include_once 以及跟require的区别
    全局变量跟局部变量
    关于define
    创建、删除索引---高级部分
  • 原文地址:https://www.cnblogs.com/pythonSF/p/14488499.html
Copyright © 2020-2023  润新知