commands.sh

timeout

all

Run a command with a time limit.

More info →

Options (4)

-s, --signalboolean

Send a signal to the command after the time limit expires (`TERM` by default, `kill -l` to list all signals)

Example: timeout {{[-s|--signal]}} {{INT|HUP|KILL|...}} {{5s}} {{sleep 10}}
-v, --verboseboolean

Send verbose output to `stderr` showing signal sent upon timeout

Example: timeout {{[-v|--verbose]}} {{0.5s|1m|1h|1d|...}} {{command}}
-p, --preserve-statusboolean

Preserve the exit status of the command regardless of timing out

Example: timeout {{[-p|--preserve-status]}} {{1s|1m|1h|1d|...}} {{command}}
-k, --kill-afterboolean

Send a forceful `KILL` signal after certain duration if the command ignores initial signal upon timeout

Example: timeout {{[-k|--kill-after]}} {{5m}} {{30s}} {{command}}

Examples (5)

Run `sleep 10` and terminate it after 3 seconds

Send a signal to the command after the time limit expires (`TERM` by default, `kill -l` to list all signals)

timeout [-s|--signal] INT|HUP|KILL|... 5s sleep 10

Send verbose output to `stderr` showing signal sent upon timeout

timeout [-v|--verbose] 0.5s|1m|1h|1d|... command

Preserve the exit status of the command regardless of timing out

timeout [-p|--preserve-status] 1s|1m|1h|1d|... command

Send a forceful `KILL` signal after certain duration if the command ignores initial signal upon timeout

timeout [-k|--kill-after] 5m 30s command
made by @shridhargupta | data from tldr-pages