redhat设置系统启动/关机过程中处理自动启动服务命令

时间:2022-10-22 15:39:45

与ubuntu不一样

它使用的是chkconfig

                                                                                                              
[root@uhza006680 ~]# chkconfig                                                                                                             
chkconfig 版版本本 1.3.30.2 - 版版权权 (C) 1997-2000 Red Hat, Inc.                                                                                 
在在 GNU 公公共共许许可可的的条条款款下下,,本本软软件件可可以以被被自*由发发行行。。                                                                                            
                                                                                                                                           
用用法法::    chkconfig --list [name]                                                                                                          
         chkconfig --add <name>                                                                                                            
         chkconfig --del <name>                                                                                                            
         chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities>



---------------列举服务状态------


 chkconfig --list                                                                                                      
NetworkManager  0:关关闭闭  1:关关闭闭  2:关关闭闭  3:关关闭闭  4:关关闭闭  5:关关闭闭  6:关关闭闭                                                                     
acpid           0:关关闭闭  1:关关闭闭  2:启启用用  3:关关闭闭  4:关关闭闭  5:关关闭闭  6:关关闭闭                                                                     
anacron         0:关关闭闭  1:关关闭闭  2:启启用用  3:关关闭闭  4:关关闭闭  5:关关闭闭  6:关关闭闭                                                                     
atd             0:关关闭闭  1:关关闭闭  2:关关闭闭  3:关关闭闭  4:关关闭闭  5:关关闭闭  6:关关闭闭                                                                     
auditd          0:关关闭闭  1:关关闭闭  2:启启用用  3:关关闭闭  4:关关闭闭  5:关关闭闭  6:关关闭闭                                                                     
autofs          0:关关闭闭  1:关关闭闭  2:关关闭闭  3:启启用用  4:启启用用  5:启启用用  6:关关闭闭                                                                     
avahi-daemon    0:关关闭闭  1:关关闭闭  2:关关闭闭  3:关关闭闭  4:关关闭闭  5:关关闭闭  6:关关闭闭                                                                     
avahi-dnsconfd  0:关关闭闭  1:关关闭闭  2:关关闭闭  3:关关闭闭  4:关关闭闭  5:关关闭闭  6:关关闭闭


1-6 level的对应说明

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


所以,如果想设置某个服务在某个阶段启动或是关闭,使用以下命令


                                                               
[root@uhza006680 ~]# chkconfig --level 2345 httpd on                                                                                       
[root@uhza006680 ~]# chkconfig --level 2345 mysqld on                       

即可设置服务在启动的阶段自动启动.