Add request timestamp with CURL

18,506

If I'm understanding and you're wanting to measure latency client-side where curl is, you can use --write-out How do I measure request and response times at once using cURL?

Server-side, unless someone customized the log, every hit to the server should log both date and time in the access_log

::1 - - [25/Mar/2016:22:37:54 -0700] "GET / HTTP/1.1" 200 38

EDIT:

Okay, given what you want.. not sure what it would show, since requests take portions of seconds, and clocks on different computers aren't necessarily the same. Nevertheless, to send the client's date with the curl request, you can capture the timestamp and send it as part of a custom user-agent using the -A option.

e.g. if in a unix bash shell that supports nanoseconds

curl -A `date +"[mycurltime:%Y-%m-%dT%H:%M:%S.%3N]"` "http://hostname/etc"

results in...

your.ip.addy - - [26/Mar/2016:16:52:54 -0700] "GET /etc HTTP/1.1" 200 7502 "-" "[mycurltime:2016-03-26T16:52:54.437]"
Share:
18,506
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm working in a small LINUX project to calculate requests latency with CURL and a remote website.

    So I made a shell script to send automatically GET requests to the remote Apache Webserver. And while accessing Apache's access.log I only find the time when requests from CURL were received by apache only.

    Is it possible to also send the date of the CURL request to apache server? (Timestamp)

    Thanks