Placeholder for our stuff related to Telecom, IT, Internet of things (IOT), ESP8266, Raspberry Pi

Home IOT Telecom IT stuff About Us Contact Us Site Map

Ping Drop Capture Script for Linux

This script will ping specified host periodically and display the result. You can save results to a logfile. I will show you how you can run this script unattended so that output will keep logging in a file even-if you close your ssh/telnet session.

This will help you capture intermittent ping drops between two nodes.

The script will send one ping every second and display the result on screen. You can increase the sleep time as per your requirement by changing "sleep 1". For example "sleep 5" will send one ping every 5 seconds.

Make the script executable by following command

chmod +x myPingScript.sh 




./myPingScript.sh google.com

Ping Image

Ping Result Down Image

To capture result in a log file use linux output redirection

./myPingScript.sh >> myLogFile.txt &

If you are interested in capturing only down times then use grep.

./myPingScript.sh | grep down >> myLogFile.txt

To get the output on the console AND in a file

./myPingScript.sh | tee myLogFile.txt

Ensure that you have write permissions on filepath.

Running script in background

Running script with nohup will keep it running in background.

nohup command line-utility allows to run command/process or shell script that can continue running in the background after you log out from a shell.

nohup ./myPingScript.sh | grep down >> myLogFile.txt

 Ping nohup


Script to log RTT crossing threshold


myPingScript.sh [host] [min RTT] [sleepTime]
it will print output if RTT is more then specified value
sleepTime is in seconds and can be in decimals like 0.1

# ./myPingScript.sh 33.1 0.5





Suresh Hariramani

I am an IOT enthusiast with more than 20 years of experience in the IT sector. Specializing in telecom service's; follow me for some very innovative and best in class IOT products as I unfold my knowledge and passion for the subject.


Vatsal Hariramani

Just me, myself and I, exploring the universe of uknownment. I have a heart of love and interests in technology, IOT and travel . And I want to share my world with you .