彻底关闭ntsysv中关闭的服务

回复 收藏
有些服务在图形界面里通过ntsysv关闭以后,在非图形界面仍然开启。写一个脚本关闭它们。明天奉上我的脚本。
2016-03-23 23:27 举报
已邀请:
0

Neo

赞同来自:

#!/bin/bash
#this shell script is used to shutdown services that is off in lever15 by shell
#order chkconfig.once  you run this shell script then restart the system,it will
#permanently get effective.
#if you want to start closed services,you can run "chkconfig servicename on" in
#shell in terms of root privillage.
chkconfig|awk '/1:off/&&/3:on/&&/5:off/{print $1}' >> servicesoff
sum=`grep -c '.' servicesoff`
echo "shutdown services amount: $sum"
oIFS=$IFS
IFS=" "
while read service
do
chkconfig $service off
done rm -f servicesoff
0

kw是id

赞同来自:

#!/bin/bash
ver=`cat /etc/issue|head -n1 |awk '{print $3}'|awk -F '.' '{print $1}'`
svr_list=/tmp/startup.txt
if [ $ver -ne 6 ]
then
   echo "This sccript suitable for Centos release 6.x"
   exit 1
fi
[ -e $svr_list ] || touch $svr_list
if [ ! -s $svr_list ]
then
    echo "please input the server name you want to start when system boot into $svr_list"
    echo "one server name ONE LINE or one server name ONE SPACE"
    exit 1
fi
for i in `chkconfig --list |awk '{print $1}'`
do
  chkconfig $i off
done
for a in `cat $svr_list`
do
  chkconfig $a --level 3 on
done

回复帖子,请先登录注册

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