man chkconfig For example, random.init has these three lines: # chkconfig: 2345 20 80 解释:2345 是在这几个级别上默认on 20 80 是启动关闭顺序 # description: Saves and restores system entropy pool for
# higher quality random number generation.

**重点:**需要把脚本放在/etc/init.d/目录下

添加:

[root@csa ~]# vim nopsmile.sh 
#!/bin/sh
# chkconfig: 2345 20 80
# description: test
echo "I'm nopsmile"

[root@csa ~]# mv nopsmile.sh /etc/init.d/
[root@csa ~]# chkconfig --add nopsmile.sh 
[root@csa ~]# chkconfig --list | grep nopsmile
nopsmile.sh     0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@csa ~]# ls -l /etc/rc.d/rc3.d/*nopsmile*
lrwxrwxrwx 1 root root 21 Mar 16 09:09 /etc/rc.d/rc3.d/S20nopsmile.sh -> ../init.d/nopsmile.sh

[root@csa ~]# chkconfig --level 3 nopsmile.sh off
[root@csa ~]# chkconfig --list | grep nopsmile           
nopsmile.sh     0:off   1:off   2:on    3:off   4:on    5:on    6:off
[root@csa ~]# ls -l /etc/rc.d/rc3.d/*nopsmile*
lrwxrwxrwx 1 root root 21 Mar 16 09:16 /etc/rc.d/rc3.d/K80nopsmile.sh -> ../init.d/nopsmile.sh
[on是在S20 ,off是在K80]
删除:

[root@csa ~]# chkconfig --del nopsmile.sh 
[root@csa ~]# chkconfig --list | grep nopsmile
结果是空。
[root@csa ~]# ls -l /etc/rc.d/rc3.d/*nopsmile*
ls: cannot access /etc/rc.d/rc3.d/*nopsmile*: No such file or directory
原理:
/etc/rc.d/ 下2345 如rc3.d/添加链接