Home / Linux / How to Run a Command with Time Limit (Timeout) In Linux
How to Run a Command with Time Limit (Timeout) In Linux

How to Run a Command with Time Limit (Timeout) In Linux

How to Run a Command with Time Limit (Timeout) In Linux

Linux comes with a bounty of instructions, each and every command distinctive and utilized in explicit circumstances. The objective of Linux is to can help you be as rapid and environment friendly as conceivable. One assets of a Linux command is the point in time. You can set a point in time for any command you wish to have. If the time expires, the command stops executing.

In this quick educational, you’re going to be told two strategies on how you’ll use a point in time for your instructions.

Run Linux Commands Using the timeout Tool

Linux has a command-line application referred to as a timeout, which allows you to execute a command with a point in time.

Its syntax is as follows.


To use the command, you specify a timeout price (in seconds) with the command you wish to have to run. For example, to timeout a ping command after five seconds, you’ll run the next command.

# timeout 5s ping google.com

You should not have to specify the (s) after quantity five. The command beneath is identical and can nonetheless paintings.

# timeout five ping google.com
Timeout Ping Command in Linux

Timeout Ping Command in Linux

Other suffixes come with:

  • m representing mins
  • h representing hours
  • d representing days

Sometimes instructions might proceed to run even after timeout sends the preliminary sign. In such circumstances, you’ll use the --kill-after choice.

Here’s the syntax.

-k, --kill-after=DURATION

You want to specify a period to let timeout know after how a lot time the kill sign is to be despatched.

For instance, the command proven goes to be terminated after eight seconds.

# timeout 8s tail -f /var/log/syslog
Set Time Limit to Linux Commands

Set Time Limit to Linux Commands

Run Linux Commands Using Timelimit Program

The Timelimit program runs a given command then terminates the method after a specified time the use of a given sign. It to begin with passes a caution sign, after which after a timeout, it sends the kill sign.

Unlike the timeout choice, Timelimit has extra choices reminiscent of killsig, warnsig, killtime, and warntime.

Timelimit will also be discovered within the repositories of Debian-based methods and to set up it, use the next command.

$ sudo apt set up timelimit

For Arch-based methods, you’ll set up it the use of AUR helper techniques e.g., Pacaur Pacman, and Packer.

# Pacman -S timelimit
# pacaur -S timelimit
# packer -S timelimit

Other Linux distributions, you’ll obtain timelimit supply and manually set up it.

After set up, run the next command and specify the time. In this case, you’ll use 10 seconds.

$ timelimit -t10 tail -f /var/log/pacman.log

Note that if you happen to don’t specify arguments, Timelimit makes use of the default values: warntime=3600 seconds, warnsig=15, killtime=120, and killsig=nine.


In this information, you have got discovered how to run instructions with a point in time in Linux. In overview, you’ll use the Timeout command or the Timelimit application.

The Timeout command is straightforward to use, however the Timelimit application is a bit sophisticated however has extra choices. You can select the best option relying to your wishes.

Check Also

How to Watch TCP and UDP Ports in Real-time

How to Watch TCP and UDP Ports in Real-time

How to Watch TCP and UDP Ports in Real-time In tool phrases, particularly on the …

Leave a Reply

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


Recent Posts