chkconfigって結局なんなんだ
よくわかってなかったのでひたすら和訳してみた
$ man chkconfigしてみた
CHKCONFIG(8) CHKCONFIG(8) NAME chkconfig - updates and queries runlevel information for system services SYNOPSIS chkconfig [--list] [--type type][name] chkconfig --add name chkconfig --del name chkconfig --override name chkconfig [--level levels] [--type type] name <on|off|reset|resetpriorities> chkconfig [--level levels] [--type type] name DESCRIPTION chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories. This implementation of chkconfig was inspired by the chkconfig command present in the IRIX operating system. Rather than maintaining config- uration information outside of the /etc/rc[0-6].d hierarchy, however, this version directly manages the symlinks in /etc/rc[0-6].d. This leaves all of the configuration information regarding what services init starts in a single location. chkconfig has five distinct functions: adding new services for management, removing services from management, listing the current startup information for services, changing the startup information for services, and checking the startup state of a particular service. When chkconfig is run with only a service name, it checks to see if the service is configured to be started in the current runlevel. If it is, chkconfig returns true; otherwise it returns false. The --level option may be used to have chkconfig query an alternative runlevel rather than the current one. ... By default, the on and off options affect only runlevels 2, 3, 4, and 5, while reset and resetpriorities affects all of the runlevels. The --level option may be used to specify which runlevels are affected. Note that for every service, each runlevel has either a start script or a stop script. When switching runlevels, init will not re-start an already-started service, and will not re- stop a service that is not running. ...
見てみた
# この階層でレベルが決まる $ ll /etc lrwxrwxrwx. 1 root root 10 Oct 30 2013 rc0.d -> rc.d/rc0.d lrwxrwxrwx. 1 root root 10 Oct 30 2013 rc1.d -> rc.d/rc1.d lrwxrwxrwx. 1 root root 10 Oct 30 2013 rc2.d -> rc.d/rc2.d lrwxrwxrwx. 1 root root 10 Oct 30 2013 rc3.d -> rc.d/rc3.d lrwxrwxrwx. 1 root root 10 Oct 30 2013 rc4.d -> rc.d/rc4.d lrwxrwxrwx. 1 root root 10 Oct 30 2013 rc5.d -> rc.d/rc5.d lrwxrwxrwx. 1 root root 10 Oct 30 2013 rc6.d -> rc.d/rc6.d # mysqldは2~5がon $ chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off # mysqldを全部見てみた $ ll rc.d/rc0.d | grep mysqld lrwxrwxrwx 1 root root 16 Mar 17 08:41 K36mysqld -> ../init.d/mysqld $ ll rc.d/rc1.d | grep mysqld lrwxrwxrwx 1 root root 16 Mar 17 08:41 K36mysqld -> ../init.d/mysqld $ ll rc.d/rc2.d | grep mysqld lrwxrwxrwx 1 root root 16 Mar 17 08:41 S64mysqld -> ../init.d/mysqld $ ll rc.d/rc3.d | grep mysqld lrwxrwxrwx 1 root root 16 Mar 17 08:41 S64mysqld -> ../init.d/mysqld $ ll rc.d/rc4.d | grep mysqld lrwxrwxrwx 1 root root 16 Mar 17 08:41 S64mysqld -> ../init.d/mysqld $ ll rc.d/rc5.d | grep mysqld lrwxrwxrwx 1 root root 16 Mar 17 08:41 S64mysqld -> ../init.d/mysqld $ ll rc.d/rc6.d | grep mysqld lrwxrwxrwx 1 root root 16 Mar 17 08:41 K36mysqld -> ../init.d/mysqld
Kが停止、Sが起動で番号順に実行される
on,offに合わせて起動シェル終了シェルにシンボリックリンクがある
試してみた
# 2~5がonになっている $ chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off # 2をオフにして確認 $ sudo chkconfig --level 2 mysqld off $ chkconfig --list mysqld mysqld 0:off 1:off 2:off 3:on 4:on 5:on 6:off # シンボリックリンクを見る $ ll rc.d/rc0.d | grep mysqld lrwxrwxrwx 1 root root 16 May 18 10:19 K36mysqld -> ../init.d/mysqld $ ll rc.d/rc1.d | grep mysqld lrwxrwxrwx 1 root root 16 May 18 10:19 K36mysqld -> ../init.d/mysqld $ ll rc.d/rc2.d | grep mysqld # Kになってる lrwxrwxrwx 1 root root 16 May 18 10:19 K36mysqld -> ../init.d/mysqld $ ll rc.d/rc3.d | grep mysqld lrwxrwxrwx 1 root root 16 May 18 10:19 S64mysqld -> ../init.d/mysqld $ ll rc.d/rc4.d | grep mysqld lrwxrwxrwx 1 root root 16 May 18 10:19 S64mysqld -> ../init.d/mysqld $ ll rc.d/rc5.d | grep mysqld lrwxrwxrwx 1 root root 16 May 18 10:19 S64mysqld -> ../init.d/mysqld $ ll rc.d/rc6.d | grep mysqld lrwxrwxrwx 1 root root 16 May 18 10:19 K36mysqld -> ../init.d/mysqld
すげー
ランレベルとは
$ cat /etc/inittab ... # Default runlevel. The runlevels used are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: # centosが起動したときは3っていう設定 ...
0:停止中
1:シングルユーザモード(rootだけ)
2:NFSなしマルチユーザーモード(複数人で使用できて、CUIかGUIか選べる)
3:マルチユーザモード
4:未使用
5:X11(っていうGUIらしい)
6:再起動
ディストリビューションによって微妙に違うらしい
今のランレベルを調べる
$ runlevel N 3
一時的にランレベルを変更する
# 5にしようと思ったら再起動しろって言われた $ init 5 init: Need to be root
ちなみにhelpしてもそんなに出ない
$ chkconfig --help chkconfig version 1.3.49.3 - 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>
シンボリックリンクで管理するのが衝撃的でした
そしてググってもまともな情報がでない世の中を見てしまいました( ´∀` )