.TH tryto 1 .SH NAME tryto \- tries to run a command limited by a timeout or number of tries, can be used to run as svlogd(8) processor. .SH SYNOPSIS .B tryto [\-pPv] [\-t .IR sec ] [\-k .IR ksec ] [\-n .IR tries ] .I prog .SH DESCRIPTION .I prog consist of one or more arguments. .LP .B tryto runs and watches .IR prog , feeding its standard input to .IR prog 's standard input. If .I prog exits with a return code other then 0, .B tryto runs .I prog again after sleeping one second. .LP If the number of retries reaches the maximal number of .IR tries , .B tryto prints an error message and gives up. .LP If the timeout .I sec seconds is reached and .I prog is still running, .B tryto sends a TERM signal to .IR prog , waits .I ksec seconds for .I prog to terminate, then sends a KILL signal if .I prog still is there, and exits as soon as possible. .SH OPTIONS .TP .B \-t \fIsec timeout. Set the timeout to send TERM to .I prog to .I sec seconds. Default is 180. .TP .B \-k \fIksec kill timeout. Set the timeout to send KILL to .I prog to .I ksec seconds. Default is 5. .TP .B \-n \fItries Set the maximal number of tries to .IR tries . If .I prog exited with a return code other that 0, .B tryto tries to rewind standard input to the beginning using .BR lseek (2) before starting .I prog again. Default is 5. .TP .B \-p processor. Use this option if you run .B tryto as a .BR svlogd (8) processor (see below). .TP .B \-P process group. Run .I prog in a new session and process group, and send signals on timeout to .IR prog 's process group instead of its pid. .TP .B \-v verbose. Print verbose messages to standard error. .SH PROCESSOR If .B tryto sees the .B \-p option, .B tryto runs as a .BR svlogd (8) or .BR multilog (8) processor, making use of filedescriptors 4 and 5: .LP Before starting .IR prog , .B tryto moves the filedescriptor 5 to 2, so all error messages from .B tryto and .I prog will be saved in .BR svlogd (8)'s .I state to be processed on the next run of .B tryto .BR \-p . .LP After starting .IR prog , .B tryto first feeds all data it reads from filedescriptor 4 into .IR prog 's standard input, then all data from filedescriptor 0. .LP If .I prog fails by timeout .I sec seconds or maximal number of .IR tries , .B tryto prints all data from standard input to standard output, an error message to standard error, and exits with 0. .SH EXIT CODES If .B tryto itself fails, it returns 111. .LP If .B tryto runs as a .BR svlogd (8) processor, .B tryto returns 0 in all other cases. .LP If .I prog was run successfully, .B tryto returns 0. .LP If .I prog failed by timeout, .B tryto returns 100. .LP If .I prog failed by maximal number of .IR tries , .B tryto returns the last return code from .IR prog . .LP .SH SEE ALSO socklog(8), uncat(1), svlogd(8), multilog(8), lseek(2) .LP http://smarden.org/socklog/ http://smarden.org/runit/ .SH AUTHOR Gerrit Pape