TIMEOUT(1) | User Commands | TIMEOUT(1) |
timeout - execute a command with a time limit
timeout [-k time] [-s signal] [-fp] time command [argument ...]
Timeout executes a specified command and attempts to terminate it after an also specified time. Per default, it sends signal 15 (terminate, alias SIGTERM), but the signal can be redefined (see option If the duration is a zero value, the timer is disabled (see timer_settime(2)), ergo there will not be any signal sent to the specified command's process.
It accepts the following options:
time can be specified as a fractional number by using a full stop or a comma as the decimal separator. The default value are seconds unless a time unit is specified per its single-letter identifier; in ascend order, the supported units are:
Exit status is 124 if the timer expired and the -p option was not set, 126 if the command could be found, but could not be executed and 127 if the command could not be found.
This program has different possible applications in one's routine,
here are some:
Lets suppose you need to check if your system is connected to the Internet and
that it can successfully connect to a server in less than 5 seconds, you can
use timeout along with nc(1):
% timeout -p 5 nc -vz pindorama.dob.jp 80 % echo $? 0
Although this implementation being sœur with BSDs'
implementations since it shares some parts of code with it, it does not
support long options as GNU (and BSDs') does, so some shell scripts may not
work unchanged with this implementation.
An abideable approach for solving this problem could be an small check/wrapper
for the timeout command in case of utilizing the -f or the -p options in its
long format.
if test `getconf HEIRLOOM_TOOLCHEST_VERSION` -ge 20240220 then
timeout -p -ktime time command else
timeout --preserve-duration --kill-after time time command fi
This implementation supports intervals using both European or Anglo decimal separators, GNU doesn't.
In contrast to OpenBSD's — and any other implementation thoroughly based and/or ported from FreeBSD 10.3R —, this implementation supports nanoseconds as the interval instead of microseconds. This can change in the future depending on your platform, though.
exec(3), fork(2), kill(1), signal(2), timer_settime(2), itimerspec(3type), wait(2)
The timeout utility first appeared as a proposal in BusyBox mailing lists in February 3, 2006, but this version have payloads closer to the timeout found at GNU Coreutils 7.0, released in 05 October, 2008.
2/20/24 | Heirloom Toolchest |