监控网站关键字的shell脚本,供大家学习参考。
脚本部分字段说明:
/root/sh/URL_txt 监控url列表 格式如下:
脚本如下,我放在/root/sh下:
复制代码代码如下:
#!/bin/bash
export LANG=en_US.UTF-8 DATA=`date +%Y-%m-%d_%H:%M` echo "" >/tmp/send.txt ERROR=0 cd /root/sh cat URL_txt | grep -v "#" >/root/sh/check_tmp.txt for URL_all in `cat /root/sh/check_tmp.txt` do URL_yuming=`echo $URL_all |awk -F '/' '{print $3}'` URL_url=`echo $URL_all |awk -F '!' '{print $1}'| cut -d '/' -f 4-` URL_guanjianzi=`echo $URL_all |awk -F '!' '{print $2}'` /bin/check_http -H $URL_yuming -u /$URL_url -s $URL_guanjianzi >/dev/null //如果要调试,去掉>/dev/null if [ $? != 0 ];then echo "$URL_all" >>/tmp/send.txt ERROR=1 fi done if [ "$ERROR" == "1" ];then cat /tmp/send.txt | /usr/local/mutt/bin/mutt -s "check_web_key is error" 281450202@qq.com else echo ""$DATA" check web key all ok " >>/tmp/history.txt fi |