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

原文链接: http://www.cnblogs.com/zengjieboke/p/7101996.html
#!/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

  

转载于:https://www.cnblogs.com/zengjieboke/p/7101996.html

你可能感兴趣的:(批量检查多个网址是否正常(shell编程))