1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
.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 <pape@smarden.org>
|