#!/bin/bash
#description:这个脚本通过读取另外一个文件的modify_time,来判断是否web重启!
#author:jinlongcui
set -x
export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
#记录重启时间的log
Reload_time=/home/scripts/reload_time
##定义需要查看的文件
File=/opt/case/www/switch
##定义存放modify值的文件
Log_File=/home/scripts/switch_first
##截取一段能够区分文件状态的值
Value_First="$(stat $File|grep -i modify|awk '{print $3}' )"
###定义一个对比值
Value_File="$(cat $Log_File)"
##判断两个值是否一致,不一致则同步
if [ $Value_File == $Value_First ]
then
exit 0
else
echo $Value_First > $Log_File
/opt/app/nginx/sbin/nginx -t | grep 'test is successful' >/dev/null
if [ $? -gt 0 ]; then
/opt/app/nginx/sbin/nginx -s reload
echo "`date +%F` is reloaded" >>$Reload_time
else
echo "The 182 reload failed at $Time!"| mail -s "$FLAG,$Time" xxxxxxxxxx@139.com -- -f warnning@support.com
fi
fi
阅读(2096) | 评论(0) | 转发(0) |