1. 程式人生 > >隨機訪問web

隨機訪問web

random $? log ++ done stat run ebs date

#!/bin/bash

ip_list=([0]="1.1.1.1" [1]="2.2.2.2" [2]="3.3.3.3")
i=0
while true
do
run_time=date +"%Y-%m-%d %H:%M:%S"
randnum=$(($RANDOM%3))
http_code=curl -m 5 -o /dev/null -s -w %{http_code} http://www.baidu.com/ -x ${ip_list[$randnum]}:80
curl_status="$?"
test "x${curl_status}" != "x0" && echo "==${curl_status}==${run_time}==${i}==" >> curl_errorn.log

((i++))
echo "==id:${i}==time:${run_time}==http_code:${http_code}" >> ./curl_website_count.log
test "x$i" == "x20" && echo "==${run_time}==end==${i}==" && exit 0
done

隨機訪問web