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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>tryto(1) manual page</title>
</head>
<body bgcolor='white'>
<a href='https://smarden.org/pape/'>G. Pape</a><br><a href='index.html'>socklog</A><hr><p>
<h2><a name='sect0'>Name</a></h2>
tryto - tries to run a command limited by a timeout or number of tries,
can be used to run as <i>svlogd(8)</i> processor.
<h2><a name='sect1'>Synopsis</a></h2>
<b>tryto</b> [-pPv] [-t <i>sec</i>] [-k
<i>ksec</i>] [-n <i>tries</i>] <i>prog</i>
<h2><a name='sect2'>Description</a></h2>
<i>prog</i> consist of one or more arguments. <p>
<b>tryto</b>
runs and watches <i>prog</i>, feeding its standard input to <i>prog</i>’s standard input.
If <i>prog</i> exits with a return code other then 0, <b>tryto</b> runs <i>prog</i> again after
sleeping one second. <p>
If the number of retries reaches the maximal number
of <i>tries</i>, <b>tryto</b> prints an error message and gives up. <p>
If the timeout <i>sec</i>
seconds is reached and <i>prog</i> is still running, <b>tryto</b> sends a TERM signal
to <i>prog</i>, waits <i>ksec</i> seconds for <i>prog</i> to terminate, then sends a KILL signal
if <i>prog</i> still is there, and exits as soon as possible.
<h2><a name='sect3'>Options</a></h2>
<dl>
<dt><b>-t <i>sec</b> </i></dt>
<dd>timeout.
Set the timeout to send TERM to <i>prog</i> to <i>sec</i> seconds. Default is 180. </dd>
<dt><b>-k <i>ksec</b>
</i></dt>
<dd>kill timeout. Set the timeout to send KILL to <i>prog</i> to <i>ksec</i> seconds. Default
is 5. </dd>
<dt><b>-n <i>tries</b> </i></dt>
<dd>Set the maximal number of tries to <i>tries</i>. If <i>prog</i> exited with
a return code other that 0, <b>tryto</b> tries to rewind standard input to the
beginning using <i><b>lseek</b>(2)</i> before starting <i>prog</i> again. Default is 5. </dd>
<dt><b>-p</b> </dt>
<dd>processor.
Use this option if you run <b>tryto</b> as a <i><b>svlogd</b>(8)</i> processor (see below). </dd>
<dt><b>-P</b>
</dt>
<dd>process group. Run <i>prog</i> in a new session and process group, and send signals
on timeout to <i>prog</i>’s process group instead of its pid. </dd>
<dt><b>-v</b> </dt>
<dd>verbose. Print verbose
messages to standard error. </dd>
</dl>
<h2><a name='sect4'>Processor</a></h2>
If <b>tryto</b> sees the <b>-p</b> option, <b>tryto</b> runs
as a <i><b>svlogd</b>(8)</i> or <i><b>multilog</b>(8)</i> processor, making use of filedescriptors
4 and 5: <p>
Before starting <i>prog</i>, <b>tryto</b> moves the filedescriptor 5 to 2, so
all error messages from <b>tryto</b> and <i>prog</i> will be saved in <i><b>svlogd</b>(8)</i>’s <i>state</i>
to be processed on the next run of <b>tryto </b> <b>-p</b>. <p>
After starting <i>prog</i>, <b>tryto</b>
first feeds all data it reads from filedescriptor 4 into <i>prog</i>’s standard
input, then all data from filedescriptor 0. <p>
If <i>prog</i> fails by timeout <i>sec</i>
seconds or maximal number of <i>tries</i>, <b>tryto</b> prints all data from standard
input to standard output, an error message to standard error, and exits
with 0.
<h2><a name='sect5'>Exit Codes</a></h2>
If <b>tryto</b> itself fails, it returns 111. <p>
If <b>tryto</b> runs as
a <i><b>svlogd</b>(8)</i> processor, <b>tryto</b> returns 0 in all other cases. <p>
If <i>prog</i> was run
successfully, <b>tryto</b> returns 0. <p>
If <i>prog</i> failed by timeout, <b>tryto</b> returns
100. <p>
If <i>prog</i> failed by maximal number of <i>tries</i>, <b>tryto</b> returns the last return
code from <i>prog</i>. <p>
<h2><a name='sect6'>See Also</a></h2>
<i>socklog(8)</i>, <i>uncat(1)</i>, <i>svlogd(8)</i>, <i>multilog(8)</i>, <i>lseek(2)</i>
<p>
<i>https://smarden.org/socklog/</i><br>
<i>https://smarden.org/runit/</i><br>
<h2><a name='sect7'>Author</a></h2>
Gerrit Pape <pape@smarden.org> <p>
<hr><p>
<a name='toc'><b>Table of Contents</b></a><p>
<ul>
<li><a name='toc0' href='#sect0'>Name</a></li>
<li><a name='toc1' href='#sect1'>Synopsis</a></li>
<li><a name='toc2' href='#sect2'>Description</a></li>
<li><a name='toc3' href='#sect3'>Options</a></li>
<li><a name='toc4' href='#sect4'>Processor</a></li>
<li><a name='toc5' href='#sect5'>Exit Codes</a></li>
<li><a name='toc6' href='#sect6'>See Also</a></li>
<li><a name='toc7' href='#sect7'>Author</a></li>
</ul>
</body>
</html>
|