TIMELIMIT(1) | General Commands Manual | TIMELIMIT(1) |
timelimit
—
effectively limit the absolute execution time of a
process
timelimit |
[-pq ] [-S
killsig] [-s
warnsig] [-T
killtime] [-t
warntime] command
[arguments ...] |
timelimit |
--features |
The timelimit
utility executes a given
command with the supplied
arguments and terminates the spawned process after a
given time with a given signal. If the process exits before the time limit
has elapsed, timelimit
will silently exit, too.
Options:
--features
timelimit
:
-p
timelimit
propagates this condition, i.e. sends
the same signal to itself. This allows the program executing
timelimit
to determine whether the child process
was terminated by a signal or actually exited with an exit code larger
than 128.-q
timelimit
does not output
diagnostic messages about signals sent to the child process.-S
killsig-s
warnsig-T
killtime-t
warntimeOn systems that support the setitimer(2) system call, the warntime and killtime values may be specified in fractional seconds with microsecond precision.
If the child process exits normally, the
timelimit
utility will pass its exit code on up. If
the child process is terminated by a signal and the
-p
flag was not specified, the
timelimit
utility's exit status is 128 plus the
signal number, similar to sh(1). If the
-p
flag was specified, the
timelimit
utility will raise the signal itself so
that its own parent process may in turn reliably distinguish between a
signal and a larger than 128 exit code.
In rare cases, the timelimit
utility may
encounter a system or user error; then, its exit status is one of the
standard sysexits(3) values:
EX_USAGE
EX_SOFTWARE
timelimit
utility itself received an
unexpected signal while waiting for the child process to terminate.EX_OSERR
timelimit
utility was unable to execute the
child process, wait for it to terminate, or examine its exit status.The following examples are shown as given to the shell:
timelimit -p /usr/local/bin/rsync
rsync://some.host/dir /opt/mirror
Run the rsync program to mirror a WWW or FTP site and kill it if
it runs longer than 1 hour (that is 3600 seconds) with SIGTERM. If the rsync
process does not exit after receiving the SIGTERM,
timelimit
issues a SIGKILL 120 seconds after the
SIGTERM. If the rsync process is terminated by a signal,
timelimit
will itself raise this signal.
tcpserver 0 8888 timelimit -t600
-T300 /opt/services/chat/stats
Start a tcpserver(n) process listening on tcp port 8888; each client connection shall invoke an instance of an IRC statistics tool under /opt/services/chat and kill it after 600 seconds have elapsed. If the stats process is still running after the SIGTERM, it will be killed by a SIGKILL sent 300 seconds later.
env WARNTIME=4.99 WARNSIG=1
KILLTIME=1.000001 timelimit sh stats.sh
Start a shell script and kill it with a SIGHUP in a little under 5 seconds. If the shell gets stuck and does not respond to the SIGHUP, kill it with the default SIGKILL just a bit over a second afterwards.
No standards documentation was harmed in the process of creating
timelimit
.
Please report any bugs in timelimit
to the
author.
The timelimit
utility was conceived and
written by Peter Pentchev
⟨roam@ringlet.net⟩ with contributions and suggestions by
Karsten W Rohrbach
⟨karsten@rohrbach.de⟩, Teddy Hogeborn
⟨teddy@fukt.bsnet.se⟩, and Tomasz
Nowak ⟨nowak2000@poczta.onet.pl⟩.
April 14, 2018 | Debian |