Redhat6上批次開關服務 chkconfig快速批次設定服務的shell指令碼

2020-08-12 22:27:58

使用chkconfig批次開關開機自啓動服務:

for services in `chkconfig --list|grep "3:on"|awk '{print $1}'|grep -vE "crond|irqbalance|network|rsyslog|sshd"`; do chkconfig --level 3 $services off; done
#獲取排除crond|irqbalance|network|rsyslog|sshd之外所有3:on的service,並把它們都關閉;
for services in crond irqbalance network rsyslog sshd; do chkconfig --level 3 $services on; done
#查詢crond|irqbalance|network|rsyslog|sshd五項服務,並把他們的level3 都設定爲on的狀態;
chkconfig --list|grep "3:on"|awk '{print $1}'
#列出所有 "3:on"的服務,確保只有這5項被開啓: