commands

timeout — bound command duration

GNU timeout runs a command with a deadline; TERM is default. Status 124 normally means timeout, 125 internal failure, 126 cannot invoke, 127 not found. Not an isolation mechanism. Use a fresh private workspace, ordinary user and bounded child processes; no sudo.

Formal Syntax & Structure

linux syntaxlinux
timeout DURATION COMMAND [ARG...]

Parameters & Attributes

NameTypeDescription
DURATIONoperanddeadline
COMMANDoperandbounded command
ARGoperandarguments

Return Value

exit status and output

GNU timeout runs a command with a deadline; TERM is default. Status 124 normally means timeout, 125 internal failure, 126 cannot invoke, 127 not found. Not an isolation mechanism.

Working Example

Example Snippetlinux
if timeout 0.1 sleep 1; then printf 'completed\n'; else printf 'status=%s\n' "$?"; fi
Linux Reference