1 .\" Copyright (c) 2001, 2007 - 2010 Peter Pentchev
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .Dd September 29, 2010
32 .Nd effectively limit the absolute execution time of a process
45 utility executes a given
49 and terminates the spawned process after a given time with a given signal.
50 If the process exits before the time limit has elapsed,
52 will silently exit, too.
55 .Bl -tag -width indent
57 If the child process is terminated by a signal,
59 propagates this condition, i.e. sends the same signal to itself.
60 This allows the program executing
62 to determine whether the child process was terminated by a signal or
63 actually exited with an exit code larger than 128.
67 does not output diagnostic messages about signals sent to the child process.
69 Specify the number of the signal to be sent to the process
74 Defaults to 9 (SIGKILL).
76 Specify the number of the signal to be sent to the process
78 seconds after it has been started.
79 Defaults to 15 (SIGTERM).
81 Specify the maximum execution time of the process before sending
86 Defaults to 120 seconds.
88 Specify the maximum execution time of the process in seconds before sending
90 Defaults to 3600 seconds.
93 On systems that support the
99 values may be specified in fractional seconds with microsecond precision.
101 .Bl -tag -width indent
107 option was not specified.
113 option was not specified.
119 option was not specified.
125 option was not specified.
128 If the child process exits normally, the
130 utility will pass its exit code on up.
131 If the child process is terminated by a signal and the
133 flag was not specified, the
135 utility's exit status is 128 plus the signal number, similar to
139 flag was specified, the
141 utility will raise the signal itself so that its own parent process
142 may in turn reliably distinguish between a signal and a larger than 128
147 utility may encounter a system or user error; then, its exit status is one
151 .Bl -tag -width indent
153 The command-line parameters and options were incorrectly specified.
157 utility itself received an unexpected signal while waiting for the child
158 process to terminate.
162 utility was unable to execute the child process, wait for it to terminate,
163 or examine its exit status.
167 The following examples are shown as given to the shell:
169 .Dl timelimit -p /usr/local/bin/rsync rsync://some.host/dir /opt/mirror
171 Run the rsync program to mirror a WWW or FTP site and kill it if it
172 runs longer than 1 hour (that is 3600 seconds) with SIGTERM.
173 If the rsync process does not exit after receiving the SIGTERM,
175 issues a SIGKILL 120 seconds after the SIGTERM.
176 If the rsync process is terminated by a signal,
178 will itself raise this signal.
180 .Dl tcpserver 0 8888 timelimit -t600 -T300 /opt/services/chat/stats
184 process listening on tcp port 8888; each client connection shall invoke
185 an instance of an IRC statistics tool under
186 .Pa /opt/services/chat
187 and kill it after 600 seconds have elapsed.
188 If the stats process is still running after the SIGTERM, it will be
189 killed by a SIGKILL sent 300 seconds later.
191 .Dl env WARNTIME=4.99 WARNSIG=1 KILLTIME=1.000001 timelimit sh stats.sh
193 Start a shell script and kill it with a SIGHUP in a little under 5 seconds.
194 If the shell gets stuck and does not respond to the SIGHUP, kill it
195 with the default SIGKILL just a bit over a second afterwards.
202 No standards documentation was harmed in the process of creating
205 Please report any bugs in
211 utility was conceived and written by
212 .An Peter Pentchev Aq roam@ringlet.net
213 with contributions and suggestions by
214 .An Karsten W Rohrbach Aq karsten@rohrbach.de ,
215 .An Teddy Hogeborn Aq teddy@fukt.bsnet.se ,
217 .An Tomasz Nowak Aq nowak2000@poczta.onet.pl .