zoukankan      html  css  js  c++  java
  • chkconfig

    chkconfig:
    说明:

        用来设置服务的运行级信息,该设置并非立即启动,或者禁用制定服务。

    常用参数:

    --add           增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据。
    --del            删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的叙述文件内删除相关数据。

    --level          <等级代号>  指定读系统服务要在哪一个执行等级中开启或关毕。

    等级代号说明:
    等级0表示:表示关机
    等级1表示:单用户模式
    等级2表示:无网络连接的多用户命令行模式
    等级3表示:有网络连接的多用户命令行模式
    等级4表示:不可用
    等级5表示:带图形界面的多用户模式
    等级6表示:重新启动

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

     使用范例:

    1、列出所有服务

    chkconfig --list

    2、增加服务 rhythmk

    chkconfig --add rhythmk

    3、删除服务 rhythmk

    chkconfig --del rhythmk 

    4、 设置 rhythmk 服务 在 2 3 4 5 运行基本下都是 on (开启)状态

    chkconfig --level rhythmk 2345 on 

    5、 列出 rhythmk 的 服务设置情况

    chkconfig --list rhythmk

    6、设置服务 rhythmk 所有运行等级下都是启动 

    chkconfig rhythmk on
    

    拓展:  

      1>、新建shell文件 rhythmk ,保存路径 /etc/init.d/ :

     1 #!/bin/bash
     2 # chkconfig: 2345 10 90 
     3 # description: rhythmk
     4 start() {
     5         echo "Starting"
     6 
     7 }
     8 
     9 stop() {
    10           echo "Stop"
    11 }
    12 reload() {
    13    echo "Reload"
    14 }
    15 
    16 case "$1" in
    17   start)
    18         start
    19         ;;
    20   stop)
    21         stop
    22         ;;
    23 
    24   restart)
    25         stop
    26         start
    27         ;;
    28 
    29   *)
    30 echo $"Usage: $prog {start|stop|restart}"
    31         RETVAL=2
    32 esac

    2>、为 shell 文件 rhythmk 添加 可以执行权限

    cd /etc/init.d/
    chmod u+x rhythmk
    

    3>、测试 shell

    ./rhythmk start

    service rhythmk start
    

    备注:
    需要添加如下注释,否则提示 “service rhythmk does not support chkconfig”
    # chkconfig: 2345 10 90
    # description: rhythmk

    注释#chkconfig 中2345是默认启动级别,10 90
    10是启动优先级,90是停止优先级

    4>、配置rhythmk 开机启动

     chkconfig  --add rhythmk

     

  • 相关阅读:
    C# 二维数组 排列组合
    highcharts(数据可视化框架),ajax传递数据问题
    EasyPoi导入验证功能
    EasyPoi使用入门
    SSJ(Spring+springMVC+JPA)设置xml文件思路流程
    spring框架设置jdbc
    使用JDBC完成CRUD(增删改查)
    Java的数据类型(常量,变量)
    jdk8的安装与卸载
    Java的第一个你好世界
  • 原文地址:https://www.cnblogs.com/rhythmK/p/4895030.html
Copyright © 2011-2022 走看看