批量检查多个网址是否正常(shell编程)

#!/bin/bash
#version 1.1
#by zengj
#using checking urls

. /etc/init.d/functions
 checkurl() {
     wget -o /dev/null -T 3 --tries 1 --spider $1 > /dev/null 2>&1
       if [ $? -eq 0 ]
         then
            action "this $1 is true" /bin/true
         else
            action "this $1 is bad" /bin/false
       fi
}
 wait() {
     for((i=0;i<3;i++))
      do
        if [ $i -eq 2 ]
         then
           echo "."
         else
           echo -n "."
           sleep 2
        fi
      done
}
  main(){
    array=(http://blog.oldboydu.com
           http://blog.etiantian.org
           http://oldboy.blog.51cto.com
           http://10.0.0.7
           http://www.baidu.com
)
    while(true)
    do
     echo "------this NO.$((++num)) checkurling------"
     for url in ${array[*]}
       do
         wait
         checkurl $url
       done
         sleep 10
      echo " "
    done
}
main

  

posted @ 2017-07-01 12:36  奶奶灰与爷爷白  阅读(691)  评论(0编辑  收藏  举报