1.编写bash脚本
#!/bin/bash
step=1 #间隔的秒数,不能大于60
host_list=("localhost" "192.168.75.137" "master1" "wugenqiang.master")
while [ 1 ]
do
num=$(((RANDOM%7)+1))
seq=$(((RANDOM%4)))
url="http://"${host_list[$seq]}"/"$num".html";
echo " `date +%Y-%m-%d\ %H:%M:%S` get $url"
#curl http://192.168.75.137/1.html #调用链接
curl -s $url > /dev/null
sleep $step
done
2.演示操作结果展示
[root@master1 conf]# vim test_log_records_add.sh
[root@master1 conf]# ./test_log_records_add.sh
2018-07-31 20:49:05 get http://localhost/2.html
2018-07-31 20:49:06 get http://master1/7.html
2018-07-31 20:49:07 get http://master1/1.html
2018-07-31 20:49:08 get http://localhost/7.html
2018-07-31 20:49:09 get http://wugenqiang.master/6.html
2018-07-31 20:49:10 get http://192.168.75.137/7.html
2018-07-31 20:49:11 get http://master1/4.html
2018-07-31 20:49:12 get http://localhost/7.html