zoukankan      html  css  js  c++  java
  • 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 :

  • 相关阅读:
    python活力练习Day13
    检测一个字符串在另外一个字符串中的位置
    Python活力练习Day12
    Python多进程与单进程效率对比
    HTML-Note
    Python判断自定义的参数格式是否正确
    图片的灰与彩
    Git常用命令
    Linux 单引号和双引号的区别
    类函数中获取进程池对象的地址
  • 原文地址:https://www.cnblogs.com/chenshoubiao/p/4838119.html
Copyright © 2011-2022 走看看