Run a command with a time limit.
Synopsis
timeout [OPTION] DURATION COMMAND [ARG]...
Description
Starts COMMAND, and kills it if still running after DURATION. DURATION is a number with an optional suffix: s (seconds, default), m (minutes), h (hours), d (days).
Options
-k, --kill-after=DURATION Send KILL signal after DURATION if still running.
-s, --signal=SIGNAL Specify signal to send (default: TERM).
--preserve-status Exit with the same status as COMMAND, even on timeout.
--foreground Run command in foreground.
--help Display help and exit.
Examples
$ timeout 10 curl https://example.com
Abort the request if it takes more than 10 seconds.
$ timeout 5m long-task.sh
Give a script up to 5 minutes to finish.
See Also
time, sleep