mtimeout.1: Use correct dash for number ranges.
[misc] / hush.1.in
CommitLineData
c818aced
MW
1.TH hush 1 "14 December 2011" "Edgeware tools"
2.SH NAME
3hush \- run a program, quietly unless it fails
4.SH SYNOPSIS
5.B hush
6.RB [ \-d
7.IR directory ]
8.RB [ \-m
9.IR email-address ]
10.RB [ \-n
11.IR maxlog ]
12.RB [ \-u
13.IR owner ][\fB: group ]
14.br
15 \c
16.I tag
17.I command
18.IR arguments ...
19.SH DESCRIPTION
20The
21.B hush
22program runs a command. The command's output (i.e., what it writes to
23its standard output and standard error file descriptors) is always
24logged to a file. If the command succeeds,
25.B hush
26itself outputs nothing; if it fails, then
27.B hush
28either writes the command's output to its own stdout, or sends it via
29email. It is intended to be used when running noisy programs via
30.BR cron (8),
31to reduce the amount of uninteresting mail (`cronspam') produced by an
32essentially working system.
33.PP
34The following command-line options are recognized.
35.TP
36.B \-h
37Write a help message describing
38.BR hush 's
39command line options and usage to standard output, and exit.
40.TP
41.B \-v
42Write
43.BR hush 's
44version number to standard output, and exit.
45.TP
46.BI "\-d " directory
47Write log files to
48.I directory
fd048815 49rather than the default,
c818aced
MW
50.BR "@logdir@" .
51.TP
52.BI "\-m " email-address
53Rather than writing its output to stdout if the command fails, send the
54command's output to
55.IR email-address .
56and exit with status 0. (This is perhaps a surprising choice, but it
57prevents the caller from taking additional action to report a problem
58which has already been escalated to a human.)
59.TP
60.BI "\-n " maxlog
61If necessary, delete old logfiles so that no more than
62.I maxlog
63log files are left.
64.TP
65.BI "\-p " mode
66Set the permissions on the logfile to
3ca52a3b 67.IR mode ,
c818aced 68a mode specification acceptable to
3ca52a3b
MW
69.BR chmod (1),
70though relative permissions will be applied to mode
c818aced
MW
71.B 600
72(i.e.,
73.BR u=rw,og= ).
74.TP
75.BI "\-u \fR[" user\fR][ : group\fR]
76Set the ownership and/or group of the logfile. If the
77.I user
78is specified, then the file's owner is set; if the
79.I group
80is specified, the file's group is set. (Some care is taken to ensure
81that the file is never available to members of the wrong group.)
82.SS Operation
83The given
84.I command
85is executed with the
86given
87.IR arguments ,
88with stdin redirected from
89.BR /dev/null ,
90and stdout and stderr redirected to separate pipes. If it is available,
91.BR stdbuf (1)
92is used to ensure that the
93.IR command 's
94stdout is line-buffered.
95.PP
96The
97.IR command 's
98output is collected in a log file named
99.IB logdir / tag . date # seq
100where
101.TP
102.I logdir
103is the argument of the
104.B \-d
105option, or
106.B @logdir@
107by default;
108.TP
109.I tag
110is the
111.I tag
112string given to
113.B hush
114as a command-line argument;
115.TP
116.I date
117is the current date, in ISO8601 form (in local time); and
118.TP
119.I seq
120is a sequence number, chosen to ensure that log file names are distinct
121and sort in chronological order.
122.PP
123The log file begins with a header giving the exact start time (in local
124time, with an offset from UTC) and a brief summary of the log format; it
125ends with another timestamp and the
126.IR command 's
127exit status. In between is the command's output. Lines written to
128stdout begin with
129.RB ` | ';
130lines to stderr begin with
131.RB ` * '.
132The two are interleaved in an attempt to help the reader identify how
133much progress the
134.I command
135had made when it encountered an error; however, because the streams are
136read asynchronously, this isn't perfect, and lines may appear earlier or
137later than they ought to.
138.PP
139If the
140.I command
141succeeds, as mentioned,
142.B hush
143exits without printing anything. If it fails, and the
144.B \-m
145option was given, the log file is mailed to the appropriate
146.I email-address
147with a subject line
148.IP
149.IB tag :
150.I command
151.B failed (status =
152.IB rc )
153.PP
154where
155.I rc
156is the
157.IR command 's
158exit status. If no
159.B \-m
160option was given, this log is simply written to standard output.
161.SH BUGS
162The stream interleaving isn't quite right, but it's hard to see how to
163improve it.
164.PP
165Capturing the command's output involves making a fairly large number of
166auxiliary processes and file descriptors. This is a bit ugly.
167.SH AUTHOR
168Mark Wooding, <mdw@distorted.org.uk>
169.SH SEE ALSO
170.BR cron (8).