timeout
process managementLinux
The timeout command is one of the most frequently used commands in Linux/Unix-like operating systems. timeout Run a command with a time limit
Quick Reference
Command Name:
timeout
Category:
process management
Platform:
Linux
Basic Usage:
timeout [options] [arguments]
Common Use Cases
Syntax
timeout [OPTION] DURATION COMMAND [ARG]...
Options
Option | Description |
---|---|
--preserve-status |
Exit with the same status as COMMAND, even when the command times out |
--foreground |
When not running timeout directly from a shell prompt, allow COMMAND to read from the TTY and get TTY signals |
-k, --kill-after=DURATION |
Send KILL signal if COMMAND is still running after DURATION from sending the initial signal |
-s, --signal=SIGNAL |
Specify the signal to be sent on timeout (SIGTERM by default) |
--help |
Display help information and exit |
--version |
Output version information and exit |
DURATION Format | |
DURATION is a positive integer or decimal number with an optional suffix: | |
s |
Seconds (default) |
m |
Minutes |
h |
Hours |
d |
Days |
Examples
How to Use These Examples
The examples below show common ways to use the timeout
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
# Run 'sleep 10' but terminate it after 5 seconds
timeout 5 sleep 10