Software & AppsOperating SystemLinux

How To Ping an IP Address for 60 Seconds in Linux

Ubuntu 4

When troubleshooting network connectivity or performance issues, the ping command is one of the most commonly used tools in a system administrator’s toolkit. This simple yet powerful command sends ICMP echo request packets to a specified IP address and then listens for the echo reply. The time taken for the reply to be received is reported, providing valuable information about the network latency and packet loss.

In this article, we will discuss how to use the ping command to continuously ping an IP address for a certain duration, specifically 60 seconds, in a Linux environment.

Quick Answer

To ping an IP address for 60 seconds in Linux, you can use either the -w option with the ping command or the timeout command. The -w option allows you to set a timeout for the ping command, while the timeout command terminates the ping command after a specified duration.

Understanding the Ping Command

Before we dive into the specifics, it’s important to understand the ping command and its various options. The basic syntax of the ping command is as follows:

ping [options] destination

Here, destination can be either an IP address or a domain name. The options allow you to control the behavior of the ping command. For example, you can specify the number of packets to send, the interval between packets, and the timeout period.

Pinging an IP Address for 60 Seconds

There are two main methods to ping an IP address for 60 seconds in Linux.

Method 1: Using the -w Option

The first method involves using the -w option with the ping command. The -w option allows you to specify a timeout in seconds, after which the ping command will exit, regardless of how many packets have been sent or received. Here’s an example:

ping -w 60

In this command, -w 60 sets the timeout to 60 seconds, and is the IP address being pinged. The ping command will run for 60 seconds and then stop.

Method 2: Using the timeout Command

The second method involves using the timeout command from the Coreutils package in Linux. The timeout command runs another command with a time limit for execution. Here’s how you can use it:

timeout 60 ping

In this command, timeout 60 specifies that the following command (ping should be terminated after 60 seconds.

Increasing the Number of Packets per Second

If you need to send a higher number of packets per second, you can use the -i option with a smaller interval. However, this may require superuser privileges. Here’s an example:

sudo ping -i 0.001

In this command, -i 0.001 sets the interval between packets to 0.001 seconds (or 1 millisecond), resulting in 1000 packets being sent per second. sudo is used to run the command with root privileges.


Understanding how to use the ping command effectively can greatly assist in diagnosing and resolving network issues. By specifying a duration for the ping command, you can obtain a more accurate picture of network performance over a period of time. Remember to use these commands responsibly, as excessive pinging can lead to network congestion or be seen as a form of attack.

How do I stop the `ping` command from running before the specified duration?

If you want to stop the ping command before the specified duration, you can press Ctrl + C on your keyboard. This will send an interrupt signal to the ping command and terminate it.

Can I ping a domain name instead of an IP address?

Yes, you can ping a domain name instead of an IP address. Simply replace the IP address in the ping command with the domain name. For example: ping -w 60

How can I view the packet loss and round-trip time statistics?

By default, the ping command displays the packet loss and round-trip time statistics for each packet sent. At the end of the ping session, it also provides a summary that includes the packet loss percentage and round-trip time statistics. You can use this information to analyze network performance.

Can I ping multiple IP addresses simultaneously?

Yes, you can ping multiple IP addresses simultaneously by providing them as separate arguments to the ping command. For example: ping -w 60

Is there a way to save the ping results to a file?

Yes, you can save the ping results to a file by redirecting the command’s output. For example, you can use the following command to save the output to a text file: ping -w 60 > ping_results.txt. The > symbol redirects the output to the specified file.

Leave a Comment

Your email address will not be published. Required fields are marked *