• CentOS程序 开机启动设置与chkconfig命令学习


    CentOS设置程序开机启动的方法:

    1.启动命令添加到/etc/rc.d/rc.local 文件中, 如:

    vim /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
    
    #后面添加要开机启动的程序命令如httpd
    /usr/local/apache/bin/apachectl start

    2.把写好的启动脚本添加到目录/etc/rc.d/init.d/,然后使用命令chkconfig设置开机启动。

    #把httpd的脚本写好后放进/etc/rc.d/init.d/目录
    chkconfig --add httpd    #增加所指定的系统服务
    chkconfig httpd on

    三.chkconfig命令

    chkconfig:更新(启动或停止)和查询运行级别(runlevel)信息对于系统服务.

    语法如下:

    chkconfig --list [name]:显示所有运行级系统服务的运行状态信息(on或off)。如果指定了name,那么只显示指定的服务在不同运行级的状态。

    chkconfig --add name:增加一项新的服务。chkconfig确保每个运行级有一项启动(S)或者杀死(K)入口。如有缺少,则会从缺省的init脚本自动建立。

    chkconfig --del name:删除服务,并把相关符号连接从/etc/rc[0-6].d删除

    chkconfig [--level levels] name <on|off|reset>:指定读系统服务要在哪一个执行等级中开启或关毕。

    chkconfig --level httpd 2345 on        #设置httpd在运行级别为2、3、4、5的情况下都是on(开启)的状态
    chkconfig --level 35 mysqld on        #设定mysqld在等级3和5为开机运行服务,--level 35表示操作只在等级3和5执行,on表示启动,off表示关闭
    chkconfig mysqld on        #设定mysqld在各等级为on,“各等级”包括2、3、4、5等级

    chkconfig [--level levels] name :

  • 相关阅读:
    最大团问题
    树的重心与相关性质
    2020年牛客算法入门课练习赛3 B
    牛客练习赛66 E
    浅谈后缀数组SA
    [随机化算法] 听天由命?浅谈Simulate Anneal模拟退火算法
    “优美的暴力”——树上启发式合并
    [线段树系列] LCT打延迟标记的正确姿势
    [Tarjan系列] Tarjan算法与有向图的SCC
    [Tarjan系列] 无向图e-DCC和v-DCC的缩点
  • 原文地址:https://www.cnblogs.com/chenshoubiao/p/4838119.html
Copyright © 2020-2023  润新知