您的位置:首页 > 运维架构 > Shell

运行bash脚本,访问网页,生成日志记录

2018-07-31 20:50 148 查看
版权声明:本文为博主原创学习笔记,如需转载请注明来源: https://blog.csdn.net/wugenqiang/article/details/81320418

1.编写bash脚本

[code]#!/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.演示操作结果展示

[code][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

 

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐