Ping for 60 seconds
19,182
Solution 1
From man ping
-w deadline
Specify a timeout, in seconds, before ping exits regardless of
how many packets have been sent or received. In this case ping
does not stop after count packet are sent, it waits either for
deadline expire or until count probes are answered or for some
error notification from network.
ex.
$ time ping -w60 192.168.1.65 &>/dev/null
real 1m0.001s
user 0m0.008s
sys 0m0.000s
Solution 2
The timeout command can be used also here. which is from Coreutils package in Linux. The command would be:
timeout 60 ping google.com
that's it.
Note: here you can run any command with a time limit for execution.
Author by
mgmihir
Updated on September 18, 2022Comments
-
mgmihir over 1 year
I want to ping an IP Address for 60 seconds. Like in Windows, you specify the time with '-t' flag.
ping 192.168.1.1 -t60
Is it possible in Linux?
-
mgmihir over 6 yearsThanks for the prompt reply. I am sending 1000 packets/seconds '-i 0.001'. So -c doesn't work for me.
-
John Anderson over 6 yearsHow about ping -w timeout?
-
mgmihir over 6 yearsYou can ping faster than 0.200 if you are superuser
-