首页 > 解决方案 > 使用 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 命令的新手,所以请告诉我哪里做错了。

标签: curl

解决方案


Thanks, Maxim I have also worked out a way which can be helpful.

From this answer on timestamp ts, I tried this and it works well:

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


推荐阅读