有时线上切割日志的cronolog升级了,需要把所有跑apache服务的服务器都重启一下。写了个脚本从一个文件读取需要重启的服务器列表,然后直接-k gracefull就可以了。
- [ $# -ne 1 ] && echo "$0 file" && exit
-
for HOST in $(cat $1)
-
do
-
N=$(ssh -n $HOST "ps -C httpd u| awk '/admin/{print \$11,\$12,\$13}'|uniq|wc -l" )
-
AP=$(ssh -n $HOST " ps -C httpd u|awk '/admin/{print \$11,\$12,\$13}'|uniq" )
-
if [ $N -ne 1 ];then
-
echo "发现多个配置"
-
echo $AP
-
exit 1
-
fi
-
a=0
-
echo -e "发现\e[32m$HOST\e[m配置路径:"
-
echo -e "\e[31m$AP -k graceful\e[m"
-
echo "确认重启?回车确定重启$HOST"
-
read a
-
ssh -n $HOST "$AP -k graceful" &> /dev/null
-
echo "-------------------------------------------------------------"
-
echo "重启完毕$HOST"
-
done
阅读(2025) | 评论(0) | 转发(0) |