#!/bin/bash
##name monitor_nginx_config.sh
/bin/md5sum /usr/local/nginx/conf/server.conf|awk '{print $1}' > /usr/tmp/nginx_server_conf_md5
while true
do
? ? file_path=/usr/local/nginx/conf/server.conf
? ? file_md5_old=`cat /usr/tmp/nginx_server_conf_md5`
? ? pst_name=`ps -ef|grep server.conf|grep -v grep|awk '{print $6}'`
? ? if [ -n "$pst_name" ];then
? ? ? ? who_online=`who -u|grep $pst_name`
? ? ? ? sleep 1
? ? ? ? file_md5_new=`/bin/md5sum /usr/local/nginx/conf/server.conf|awk '{print $1}'`
? ? ? ? if [ "$file_md5_new" != "$file_md5_old" ];then
? ? ? ? ? ? echo `date` $who_online >> /usr/tmp/nginx_server_change_record
? ? ? ? ? ? /bin/md5sum /usr/local/nginx/conf/server.conf|awk '{print $1}' > /usr/tmp/nginx_server_conf_md5
? ? ? ? fi
? ? fi
done