如何讓一個服務或命令經過chkconfig管理bash
1.腳本必須放在/etc/init.d目錄下面ide
[root@qyn ~]# echo "hostname" >/etc/init.d/qyndspa [root@qyn ~]# cat /etc/init.d/qyndorm hostnameip [root@qyn ~]# /etc/init.d/qyndit -bash: /etc/init.d/qyn: Permission deniedio [root@qyn ~]#table |
2.給腳本添加執行權限class
[root@qyn ~]# chmod +x /etc/init.d/qynd權限 [root@qyn ~]# ll /etc/init.d/qynd -rwxr-xr-x 1 root root 9 Aug 30 16:03/etc/init.d/qynd [root@qyn ~]# |
3.運行腳本
[root@qyn ~]# /etc/init.d/qynd qyn [root@qyn ~]# |
4.寫出chkconfig格式
默認在哪幾個運行級別啓動 開機順序 關機順序
[root@qyn ~]# vi /etc/init.d/qynd # chkconfig: 2345 99 99 # description: print hostname hostname |
5.添加到chkconfig管理
[root@qyn ~]# chkconfig --add qynd |
6.檢查
[root@qyn ~]# chkconfig | grep qynd qyn 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@qyn ~]# |