TIMEOUT(1) General Commands Manual TIMEOUT(1)

timeoutrun a command with a time limit

timeout [-f | --foreground] [-k time | --kill-after time] [-p | --preserve-status] [-s signal | --signal signal] [-v | --verbose] duration command [arg ...]

Timeout starts the command with its arg list. If the command is still running after duration, it is killed by sending the signal, or SIGTERM if the -s option is unspecified. The special duration, zero, signifies no limit. Therefore, a signal is never sent if duration is 0.

The signal dispositions inherited by the command are the same as the dispositions that timeout inherited, except for the signal that will be sent upon timeout, which is reset to take the default action and should terminate the process.

If timeout receives the SIGALRM signal, it will behave as if the time limit has been reached and send the specified signal to command. For any other signals delivered to timeout, it will propagate them to command, with the exception of SIGKILL and SIGSTOP. If you want to prevent the command from being timed out, send SIGKILL to timeout.

The options are as follows:

, --foreground
Only time out the command itself, but do not propagate signals to its descendants. See the IMPLEMENTATION NOTES section for more details.
time, --kill-after time
Send a SIGKILL signal if command is still running after time since the first signal was sent.
, --preserve-status
Always exit with the same status as command, even if the timeout was reached.
signal, --signal signal
Specify the signal to send on timeout. By default, SIGTERM is sent.
, --verbose
Show information to stderr(4) about timeouts, signals to be sent, and the command exits.

The duration and time are non-negative integer or real (decimal) numbers, with an optional suffix specifying the unit. Values without an explicit unit are interpreted as seconds.

Supported unit suffixes are:

seconds
minutes
hours
days

If the --foreground option is not specified, timeout makes itself the leader of a process group that the command inherits and sends the signal to that process group so that the command and its descendants are signalled together. A descendant that puts itself into another process group, for example by calling setsid(2), is not signalled.

Because timeout belongs to the process group it signals, and neither SIGKILL nor SIGSTOP can be caught or ignored, -s KILL and the escalation performed by -k terminate timeout along with the command, and -s STOP stops timeout along with the command, neither resuming without an external SIGCONT or SIGKILL.

With --foreground, timeout does not create a process group and signals the command directly. This is useful when timeout is not already a process group leader, as when it is run from a script rather than from a shell, where creating the process group would move the command out of the terminal's foreground process group and cause reads from the terminal to stop the command with SIGTTIN.

If the time limit was reached and the --preserve-status option is not specified, the exit status is 124. Otherwise, timeout exits with the same exit status as the command. For example, timeout will terminate itself with the same signal if the command is terminated by a signal.

If the --foreground option is not specified, -s KILL or the escalation performed by -k also sends SIGKILL to timeout, which most shells report as 137. Likewise, -s STOP stops timeout in the absence of --foreground, producing no status at all. See the IMPLEMENTATION NOTES section.

If an error occurred, the following exit values are returned:

125
An error other than the two described below occurred. For example, an invalid duration or signal was specified.
126
The command was found but could not be executed.
127
The command could not be found.

Run sleep(1) with a time limit of 4 seconds. Since the command completes in 2 seconds, the exit status is 0:

$ timeout 4 sleep 2
$ echo $?
0

Run sleep(1) for 4 seconds and terminate process after 2 seconds. The exit status is 124 since --preserve-status is not used:

$ timeout 2 sleep 4
$ echo $?
124

Same as above but preserving status. The exit status is 128 + signal number (15 for SIGTERM) for most shells:

$ timeout --preserve-status 2 sleep 4
$ echo $?
143

Same as above but sending SIGALRM (signal number 14) instead of SIGTERM:

$ timeout --preserve-status -s SIGALRM 2 sleep 4
$ echo $?
142

Try to fetch(1) the PDF version of the FreeBSD Handbook. Send a SIGTERM signal after 1 minute and send a SIGKILL signal 5 seconds later if the process refuses to stop:

$ timeout -k 5s 1m fetch \
> https://download.freebsd.org/ftp/doc/en/books/handbook/book.pdf

kill(1), nohup(1), signal(3), daemon(8)

The timeout utility is expected to conform to the specification.

The -v option and long option names are extensions to that specification.

The timeout command first appeared in FreeBSD 10.3.

The initial FreeBSD work was compatible with GNU timeout by Padraig Brady, from GNU Coreutils 8.21. The timeout utility first appeared in GNU Coreutils 7.0.

Baptiste Daroussin <bapt@FreeBSD.org>,
Vsevolod Stakhov <vsevolod@FreeBSD.org> and
Aaron LI <aly@aaronly.me>

April 11, 2026 macOS 26