chkconfig命令

检查、设置系统的各种服务。这是Red Hat公司遵循GPL规则所开发的程序,它可查询操作系统在每一个执行等级中会执行哪些系统服务,其中包括各类常驻服务。

谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。

chkconfig version 1.3.49.5 - Copyright (C) 1997-2000 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage: chkconfig [--list] [--type <type>] [name]
chkconfig --add <name>
chkconfig --del <name>
chkconfig --override <name>
chkconfig [--level <levels>] [--type <type>] <name> <on|off|reset|resetpriorities>

MySQL运行级别3的开启与关闭

使用chkconfig查看运行级别:

[root@xusx ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[root@xusx ~]# chkconfig |grep mysqld
mysqld 0:off 1:off 2:off 3:on 4:off 5:off 6:off

=====================================================================================================

使用chkconfig开启/关闭运行级别为3的mysqld

[root@xusx ~]# chkconfig --level 3 mysqld off
[root@xusx ~]# chkconfig |grep mysqld
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@xusx ~]# chkconfig --level 3 mysqld on
[root@xusx ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:on 4:off 5:off 6:off

=====================================================================================================

#创建快捷方式

=====================================================================================================

[root@xusx ~]# cd /etc/init.d/

====>写一个脚本

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[root@xusx init.d]# cat mysqld|head
#!/bin/sh
#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36
# description: MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid

[root@xusx init.d]# vim mysqlx.sh

 #!/bin/sh

#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36
# description: MySQL database server.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[root@xusx init.d]# cat iptables |head
#!/bin/sh
#
# iptables Start iptables firewall
#
# chkconfig: 2345 08 92
# description: Starts, stops and saves iptables firewall
#
# config: /etc/sysconfig/iptables
# config: /etc/sysconfig/iptables-config

[root@xusx init.d]# vim iptx.sh

#!/bin/sh
#
# iptables Start iptables firewall
#
# chkconfig: 3 108 192
# description: Starts, stops and saves iptables firewall

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

增加执行权限

chmod +x fimename.sh

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[root@xusx rc3.d]# chkconfig --add mysqlx.sh
[root@xusx rc3.d]# ll|grep mysql
lrwxrwxrwx. 1 root root 16 11月 4 00:13 K36mysqld -> ../init.d/mysqld
lrwxrwxrwx. 1 root root 19 11月 15 17:01 K88mysqlx.sh -> ../init.d/mysqlx.sh
[root@xusx rc3.d]# chkconfig |grep my
mysqld 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
mysqlx.sh 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

[root@xusx rc3.d]# chkconfig --add iptx.sh
[root@xusx rc3.d]# ll|grep ipt
lrwxrwxrwx. 1 root root 18 11月 15 06:34 K92iptables -> ../init.d/iptables
lrwxrwxrwx. 1 root root 17 11月 15 17:09 S89iptx.sh -> ../init.d/iptx.sh
[root@xusx rc3.d]# chkconfig |grep ipt
iptables 0:关闭 1:关闭 2:启用 3:关闭 4:启用 5:启用 6:关闭
iptx.sh 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:关闭 6:关闭

=====================================================================================================

 

转载于:https://www.cnblogs.com/xusx/p/6064371.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值