用脚本关闭linux不用的服务

回复 收藏
#! /bin/bash

services=`chkconfig --list|awk '{print $1}'`
for ser in $services
do
if [ "$ser" == "network" ] || [ "$ser" == "syslog" ] || [ "$ser" == "sshd" ] || \
[ "$ser" == "crond" ] || [ "$ser" == "atd" ] || [ "$ser" == "irqbalance" ] || \
[ "$ser" == "microcode_ctl" ] || [ "$ser" == "sendmail" ] ;
then
chkconfig --leve 3 "$ser" on
else
chkconfig "$ser" off
fi
done
echo "The unavaliable service has been shutdown successfully!"
sleep 5
init 6
2009-10-16 14:43 举报
已邀请:
0

llb19901227

赞同来自:

上次写了个备份脚本不小心把网站删除了~~~
0

split_two

赞同来自:

这个脚本应该把chkconfig "$ser" off 修改为chkconfig --level  12345 "$ser" off吧?
0

lyhabc

赞同来自:

chkconfig --list|awk '$1 !~ /(microcode_ctl|syslog|crond|network|irqbalance|rsyslog|sshd)/ {print "chkconfig" " " $1 " " "off"}'|bash ;init 6

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: