Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

hatimerun(1m) [opensolaris man page]

hatimerun(1M)						  System Administration Commands					     hatimerun(1M)

NAME
hatimerun - run child program under a timeout SYNOPSIS
/usr/cluster/bin/hatimerun -t timeOutSecs [-av] [-e exitcode] prog args /usr/cluster/bin/hatimerun -t timeOutSecs [-v] [-e exitcode] [-k signalname] prog args DESCRIPTION
The hatimerun utility provides a convenient facility for timing out the execution of another child, program. It is useful when programming in scripting languages, such as the Bourne shell. See sh(1). The hatimerun utility runs the program prog with arguments args as a child subprocess under a timeout, and as its own process group. The timeout is specified in seconds, by the -t timeOutSecs option. If the timeout expires, then hatimerun kills the child subprocess's process group with a SIGKILL signal, and then exits with exit code 99. You can run this command in the global zone or in a non-global zone. The command affects only the global or non-global zone in which you issue the command. OPTIONS
The following options are supported: -a Changes the meaning of hatimerun radically: instead of killing the child when the timeout expires, the hatimerun utility sim- ply exits, with exit code 99, leaving the child to run asynchronously. It is illegal to supply both the -a option and the -k option. -e Changes the exit code for the timeout case to some other value than 99. -k Specifies what signal is used to kill the child process group. The possible signal names are the same as those recognized by the kill(1) command. In particular, the signal name should be one of the symbolic names defined in the <signal.h> descrip- tion. The signal name is recognized in a case-independent fashion, without the SIG prefix. It is also legal to supply a numeric argument to the -k option, in which case that signal number is used. It is illegal to supply both the -a option and the -k option. -t Specifies the timeout period, in seconds. -v Verbose output, on stderr. EXIT STATUS
If the timeout occurs, then hatimerun exits with exit code 99 (which can be overridden to some other value using the -e option). If the timeout does not occur but some other error is detected by the hatimerun utility (as opposed to the error being detected by the child program), then hatimerunhatimerun exits with exit code 98. Otherwise, hatimerun exits with the child's exit status. The hatimerun utility catches the signal SIGTERM. It responds to the signal by killing the child as if a timeout had occurred, and then exiting with exit code 98. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
kill(1), sh(1), attributes(5) Sun Cluster 3.2 10 Apr 2006 hatimerun(1M)

Check Out this Related Man Page

TIMELIMIT(1)						    BSD General Commands Manual 					      TIMELIMIT(1)

NAME
timelimit -- effectively limit the absolute execution time of a process SYNOPSIS
timelimit [-pq] [-S killsig] [-s warnsig] [-T killtime] [-t warntime] command [arguments ...] DESCRIPTION
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: -p If the child process is terminated by a signal, 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 Quiet operation - timelimit does not output diagnostic messages about signals sent to the child process. -S killsig Specify the number of the signal to be sent to the process killtime seconds after warntime has expired. Defaults to 9 (SIGKILL). -s warnsig Specify the number of the signal to be sent to the process warntime seconds after it has been started. Defaults to 15 (SIGTERM). -T killtime Specify the maximum execution time of the process before sending killsig after warnsig has been sent. Defaults to 120 seconds. -t warntime Specify the maximum execution time of the process in seconds before sending warnsig. Defaults to 3600 seconds. On systems that support the setitimer(2) system call, the warntime and killtime values may be specified in fractional seconds with microsec- ond precision. ENVIRONMENT
KILLSIG The killsig to use if the -S option was not specified. KILLTIME The killtime to use if the -T option was not specified. WARNSIG The warnsig to use if the -s option was not specified. WARNTIME The warntime to use if the -t option was not specified. EXIT STATUS
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 spec- ified, 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 The command-line parameters and options were incorrectly specified. EX_SOFTWARE The timelimit utility itself received an unexpected signal while waiting for the child process to terminate. EX_OSERR The timelimit utility was unable to execute the child process, wait for it to terminate, or examine its exit status. EXAMPLES
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. SEE ALSO
kill(1), rsync(1), signal(3), tcpserver(n) STANDARDS
No standards documentation was harmed in the process of creating timelimit. BUGS
Please report any bugs in timelimit to the author. 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>. BSD
September 29, 2010 BSD
Man Page