In this article, we have explained how to execute a Ping test with timestamp logging.
A ping test is useful in checking network connectivity between your system and a remote host. Adding timestamps to the ping output makes it easier to track when packets were sent and received, which is useful for fixing irregular network issues.
Follow the guide:
For Linux/macOS
- Using the Built-in ‘-D’ Option:
The ‘-D’ flag adds a timestamp (in UNIX epoch format) to each line of ping output.ping -D google.com
Sample output:
[1691758201.123456] 64 bytes from 142.250.183.78: icmp_seq=1 ttl=117 time=21.3 ms [1691758202.123789] 64 bytes from 142.250.183.78: icmp_seq=2 ttl=117 time=20.9 ms
- To save the ping results with timestamps to a log file:
ping -D google.com | tee ping_log.txt
This will display the results in the terminal and store them in ‘ping_log.txt’.
- If you prefer human-readable timestamps, use the ‘date’ command:
ping google.com | while read line; do echo “$(date '+%Y-%m-%d %H:%M:%S') - $line”; done | tee ping_log.txt
Example log entry:
2025-08-11 14:23:45 - 64 bytes from 142.250.183.78: icmp_seq=1 ttl=117 time=21.3 ms
For Windows
- Run the following command using Command Prompt:
ping google.com -t
This runs a continuous ping.
- To add timestamps, execute the following:
for /f “tokens=*” %a in (‘ping google.com -t’) do @echo %date% %time% %a
- To save it to a file:
for /f “tokens=*” %a in (‘ping google.com -t’) do @echo %date% %time% %a >> ping_log.txt
Note: You can stop the test anytime by pressing ‘Ctrl + C’ on both Linux/macOS and Windows systems.
This way, using ‘ping’ with timestamp logging is a simple way to track network connectivity issues over time. On Linux/macOS, you can use the ‘-D’ flag or the ‘date’ command for readable timestamps, whereas on Windows, you can loop the ping command with date and time output.
Get reliable connectivity and full control with a Windows VPS solution.
Want more control over your tests? Learn How to start and stop ping in Linux