标签:
[root@lanny ~]# chkconfig --list|grep 3:on atd 0:off 1:off 2:on 3:on 4:on 5:on 6:off crond 0:off 1:off 2:off 3:on 4:off 5:off 6:off network 0:off 1:off 2:off 3:on 4:off 5:off 6:off rsyslog 0:off 1:off 2:off 3:on 4:off 5:off 6:off sshd 0:off 1:off 2:off 3:on 4:off 5:off 6:off sysstat 0:off 1:on 2:off 3:on 4:off 5:off 6:off
chkconfig 批量启动服务(使用循环)
输出列:awk ‘{print $1}‘
输出第一列
批量操作:两种思想:
1,先全关掉,开启需要开启的
[root@lanny ~]# chkconfig --list|grep 3:on|awk ‘{print $1}‘ atd crond network rsyslog sshd syssta 对结果进行循环 for name in `chkconfig --list|grep 3:on|awk ‘{print $1}‘`;do chkconfig $name on;done
2,关掉需要关的.
先全部打开
然后将想要排除的,用egrep -v排除掉.
然后批量关闭
chkconfig --list|grep 3:on|awk ‘{print $1}‘|egrep -v ‘crond|sshd|network|rsyslog‘
[root@lanny ~]# for name in `chkconfig --list|grep 3:on|awk ‘{print $1}‘|egrep -v ‘crond|sshd|network|rsyslog‘`;do chkconfig $name off;done [root@lanny ~]# chkconfig --list|grep 3:on crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
标签:
原文地址:http://www.cnblogs.com/iiiiher/p/5459617.html