# How to Use the timeout Command
timeout [OPTIONS] DURATION COMMAND [ARG]
# s - seconds (default)
# m - minutes
# h - hours
# d - days
# When no unit is used, it defaults to seconds. If the duration is set to zero, the associated timeout is disabled
#### Terminate a command after five seconds
timeout 5 ping 8.8.8.8
#### Terminate a command after one minute and six seconds
timeout 1.1m ping 8.8.8.8
## Sending Specific Signal
#### For example, to send SIGKILL to the ping command after one minute, you would use:
sudo timeout -s SIGKILL ping 8.8.8.8
## Killing Stuck Processes
#### In the following example, timeout runs the command for one minute, and if it is not terminated, it will kill it after ten seconds:
sudo timeout -k 10 1m ping 8.8.8.8
## Preserving the Exit Status
#### timeout returns 124 when the time limit is reached. Otherwise, it returns the exit status of the managed command
#### to return the exit status of the command even when the time limit is reached, use the --preserve-status option
timeout --preserve-status 5 ping 8.8.8.8