Technology and General Blog

In Linux operating technique, some processes run constantly, and to destroy them right after a particular quantity of time a command-line utility termed “timeout” is utilized.

The “timeout” allows the person to execute a command and then terminate it soon after a set time has handed. In other words and phrases, “timeout” tends to make it less difficult to run a command for a selected amount of money of time. The “timeout” command is incorporated in the GNU main utility kit, which will come standard with just about each individual Linux program.

In the publish-up, we will go by the fundamentals of this command with illustrations.


The “timeout” command has the following syntax:

timeout [option] [Duration] [command]

Duration can be in floating integers with time suffix:

s/no suffix (when no suffix unit is fastened it look at to second)

m= moment

h= hour

d= day

Applying the “timeout” Command

Ping your program with an IP tackle, it will preserve on likely until you terminate it by pressing CTRL+C.

Now, established a time to terminate it making use of the “timeout” command. For instance, I will established the time to 7, which implies the execution of the “ping” command will stop soon after 7 seconds.

Adhere to the underneath-provided command to established the time restrict:

$ timeout 7 ping

  • Placing Timeout with An additional Time Unit

Similarly, we can ping “” as very well, making use of:

To end the “ping” command soon after 1 minute, sort a beneath-given command in a terminal:

$ timeout 1m ping

Lots of packages despatched a price/code to the shell when they terminate.

For case in point, terminate the following approach just before it strike its time restrict that is 6 seconds. Hit CTRL+C and check out exit standing by typing “echo $”. It will return “0” in the output:

$timeout 6 ping

Interrupting a managing system will often give a “0” exit code.

Preserve standing returns an exit position even if we terminate it forcefully using CTRL+C. The command would be:

$ timeout –protect-status 2 ping

And to look at the exit code, style:

Now, the exit position will be 143.

  • Sending Indicators to Timeout

The “timeout” command sends a signal to the system to terminate it.

To verify the obtainable indicators use the “kill” command:

A checklist of all obtainable indicators will be shown.

The “-s” (–signal) option makes it possible for you to set a sign to give:

The “timeout” command works by using the “SIGTERM” to quit a system, but quite a few processes disregard the “SIGTERM” signal. To forcefully terminate a course of action utilizing the “SIGKILL” signal, can not be ignored by any process.

Sending SIGKILL to the ping command soon after 2 seconds, type:

$ sudo timeout -s SIGKILL ping

You can also mail alerts by applying a signal quantity alternatively of a signal’s name:

$ sudo timeout -s 9 ping

The “-k” solution is becoming used to terminate the system.

In the next illustration, if the link does not create in 2 minutes, it will destroy the timeout command soon after 3 seconds:

$ sudo timeout –k 3 2m ping

In my situation, the timeout command will run for 2 minutes and not be terminated. Hence, it will not get rid of even following 3 seconds.

Linux has a pretty fantastic aspect that it offers assist for each and every command we use. By employing “help” with a command title, it will give you the support information in detail:

To test the model of the timeout command, type:


In Linux functioning system, the “timeout” command is a command-line utility that is used to terminate a running approach immediately after a set time period. It is applied for the procedures that operate continually. Also, the exit position of working processes can also be accessed using the “timeout” command. We have discussed timeout commands by various examples with numerous choices.

Leave a Reply

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