chkconfig 实现在相应系统级别开启或关闭服务的原理?

[root@mfsclient ~]# chkconfig --level 3 nfs on #让NFS在字符界面开启
[root@mfsclient ~]# ll /etc/rc.d/rc3.d/ | grep nfs
lrwxrwxrwx 1 root root 17 Mar 16 2013 K86nfslock -> ../init.d/nfslock
lrwxrwxrwx 1 root root 13 Oct 22 21:46 S60nfs -> ../init.d/nfs #其实是把nfs命令链接到rc3.d下,并以S开头,代表启动!数字则是代表启动顺序
[root@mfsclient ~]# chkconfig --level 3 nfs off
[root@mfsclient ~]# ll /etc/rc.d/rc3.d/ | grep nfs
lrwxrwxrwx 1 root root 13 Oct 22 21:47 K20nfs -> ../init.d/nfs #在某个运行级别停止,则是以K开头
lrwxrwxrwx 1 root root 17 Mar 16 2013 K86nfslock -> ../init.d/nfslock

运行级别说明:

# 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) 重启


系统脚本示例:

[root@mfsclient ~]# cat /etc/init.d/nfs
#!/bin/sh
#
# nfs This shell script takes care of starting and stopping
# the NFS services.
#
# chkconfig: - 60 20 #-表标在所有的运行级别;60表示启动序号;20表示关闭序号


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章