shell脚本
通过文件里面的网址,判断是否访问成功网址
1 #!/bin/bash 2 check(){ 3 code=`curl -I -m 10 -o /dev/null -s -w %{http_code} http://$url` 4 echo $code 5 if [ $code -eq 200 ]; then 6 echo "ok" 7 else 8 echo "not ok" 9 fi 10 } 11 :<<EOF 12 while read url 13 do 14 check 15 done < url.txt 16 EOF 17 for url in `cat url.txt` 18 do 19 check 20 done
防止DDoS攻击
1 #!/bin/bash 2 webdir=/var/www/html/ 3 ##校验文件内容 4 md5sum -c --quiet /opt/webfile.db 5 if [ $? -eq 0 ]; then 6 echo "web dir is safely" 7 else 8 echo "web dir is risk" 9 fi 10 find $webdir -type f > /opt/countfile_change 11 count=$(diff /opt/countfile*|wc -l) 12 if [ $count -gt 0 ]; then 13 echo "web 被篡改!" 14 else 15 echo "ok" 16 fi