使用curl命令将时间戳和延迟输出到文件

时间:2020-03-06 12:04:34

标签: curl

我正在使用curl命令来测量日期/时间(或时间戳)以及请求的延迟。在这里执行相同的命令,对系统进行1000次压力测试,我的代码如下:

curl -s -v -i -I http://172.16.20.8:8000/files_to_curl/vid.mp4?[1-1000] | grep "Date:","%{http_code},%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total},%{size_download},%{speed_download}\n" >> test_time.txt

我的问题是我一次只能保存一个信息,如果保存了日期,则无法进行延迟,反之亦然。我是Shell命令的新手,所以请告诉我我做错了什么地方。

1 个答案:

答案 0 :(得分:1)

谢谢,马克西姆·我(Maxim)还提出了一种可能有用的方法。

从时间戳为ts的{​​{3}}的答案开始,我尝试了此方法,并且效果很好:

curl -s -v -i -I http://xxx.xx.xx.x:8000/files_to_curl/vid.mp4?[1-1000] -o /dev/null -w ",%{http_code},%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total},%{size_download},%{speed_download} \n" | ts '[%Y-%m-%d %H:%M:%S]' >> test_file.txt

相关问题