一、假設有這樣一個腳本,且放在/etc/init.d/目錄下
css
[root@oldboy init.d]# cat oldboyd # chkconfig: 2345 57 27 # description: oldboyd is a protocol for secure remote shell access. [root@oldboy init.d]# pwd /etc/init.d
二、給它執行權限
shell
[root@oldboy init.d]# chmod +x oldboyd [root@oldboy init.d]# ll oldboyd -rwxr-xr-x. 1 root root 90 Jul 14 04:28 oldboyd
三、添加chkconfig管理
ide
[root@oldboy init.d]# chkconfig --add oldboyd #添加開默認是開啓的 [root@oldboy init.d]# chkconfig --list oldboyd oldboyd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
四、chkconfig的原理實質是軟連接
spa
[root@oldboy init.d]# ll /etc/rc.d/rc3.d/|grep oldboyd lrwxrwxrwx. 1 root root 17 Jul 14 04:29 S57oldboyd -> ../init.d/oldboyd [root@oldboy init.d]# chkconfig oldboyd off [root@oldboy init.d]# ll /etc/rc.d/rc3.d/|grep oldboyd lrwxrwxrwx. 1 root root 17 Jul 14 04:30 K27oldboyd -> ../init.d/oldboyd