批量检查网站地址是否正常

#!/bin/bash
array=(
http://www.baidu.com
http://www.jd.com
http://www.taobao.com
http://111.111.111.111
)

Wait(){
  echo -n "wait 3s "
  for((i=0;i<3;i++))
  do
    echo -n "."
    sleep 1
  done
  echo
}

CheckUrl(){
  wget -t 2 -T 5 --spider $1 &> /dev/null
  if [ $? -eq 0 ];then
    echo "check $1 is OK" 
  else
    echo "check $1 is FAILED" 
  fi
  return $?
}

main(){
  Wait
  for((i=0;i<${#array[*]};i++))
  do
    CheckUrl ${array[i]}
  done
  return $?
}

main $*

 

上一篇:Linux 命令详解(六)Linux 守护进程的启动方法


下一篇:国内开源镜像站点