xref: /freebsd/usr.sbin/periodic/periodic.8 (revision 8fa113e5fc65fe6abc757f0089f477a87ee4d185)
1.\" Copyright (c) 1997 FreeBSD, Inc.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd November 28, 2001
28.Os
29.Dt PERIODIC 8
30.Sh NAME
31.Nm periodic
32.Nd run periodic system functions
33.Sh SYNOPSIS
34.Nm
35.Ar directory ...
36.Sh DESCRIPTION
37The
38.Nm
39program is intended to be called by
40.Xr cron 8
41to execute shell scripts
42located in the specified directory.
43.Pp
44One or more of the following arguments must be specified:
45.Bl -tag -width ".Pa monthly"
46.It Pa daily
47Perform the standard daily periodic executable run.
48This usually occurs early in the morning (local time).
49.It Pa weekly
50Perform the standard weekly periodic executable run.
51This usually occurs on Sunday mornings.
52.It Pa monthly
53Perform the standard monthly periodic executable run.
54This usually occurs on the first day of the month.
55.It Ar path
56An arbitrary directory containing a set of executables to be run.
57.El
58.Pp
59If an argument is an absolute directory name it is used as is, otherwise
60it is searched for under
61.Pa /etc/periodic
62and any other directories specified by the
63.Va local_periodic
64setting in
65.Xr periodic.conf 5
66(see below).
67.Pp
68The
69.Nm
70program will run each executable file in the directory or directories
71specified.
72If a file does not have the executable bit set, it is silently ignored.
73.Pp
74Each script is required to exit with one of the following values:
75.Bl -tag -width 4n
76.It 0
77The script has produced nothing notable in its output.
78The
79.Ao Ar basedir Ac Ns Va _show_success
80variable controls the masking of this output.
81.It 1
82The script has produced some notable information in its output.
83The
84.Ao Ar basedir Ac Ns Va _show_info
85variable controls the masking of this output.
86.It 2
87The script has produced some warnings due to invalid configuration settings.
88The
89.Ao Ar basedir Ac Ns Va _show_badconfig
90variable controls the masking of this output.
91.It >2
92The script has produced output that must not be masked.
93.El
94.Pp
95If the relevant variable (where
96.Aq Ar basedir
97is the base directory in which the script resides) is set to
98.Dq Li NO
99in
100.Pa periodic.conf ,
101.Nm
102will mask the script output.
103If the variable is not set to either
104.Dq Li YES
105or
106.Dq Li NO ,
107it will be given a default value as described in
108.Xr periodic.conf 5 .
109.Pp
110All remaining script output is delivered based on the value of the
111.Ao Ar basedir Ac Ns Va _output
112setting.
113.Pp
114If this is set to a path name (beginning with a
115.Ql /
116character), output is simply logged to that file.
117.Xr newsyslog 8
118knows about the files
119.Pa /var/log/daily.log , /var/log/weekly.log
120and
121.Pa /var/log/monthly.log ,
122and if they exist, it will rotate them at the appropriate times.
123These are therefore good values if you wish to log
124.Nm
125output.
126.Pp
127If the
128.Ao Ar basedir Ac Ns Va _output
129value does not begin with a
130.Ql /
131and is not empty, it is assumed to contain a list of email addresses, and
132the output is mailed to them.
133.Pp
134If
135.Ao Ar basedir Ac Ns Va _output
136is not set or is empty, output is sent to standard output.
137.Sh ENVIRONMENT
138The
139.Nm
140command sets the
141.Ev PATH
142environment to include all standard system directories, but no additional
143directories, such as
144.Pa /usr/local/bin .
145If executables are added which depend upon other path components, each
146executable must be responsible for configuring its own appropriate environment.
147.Sh FILES
148.Bl -tag -width ".Pa /etc/periodic.conf"
149.It Pa /etc/crontab
150The
151.Nm
152program is typically called via entries in the system default
153.Xr cron 8
154table.
155.It Pa /etc/periodic
156The top level directory containing
157.Pa daily ,
158.Pa weekly ,
159and
160.Pa monthly
161subdirectories which contain standard system periodic executables.
162.It Pa /etc/defaults/periodic.conf
163The
164.Pa periodic.conf
165system registry contains variables that control the behaviour of
166.Nm
167and the standard
168.Pa daily , weekly ,
169and
170.Pa monthly
171scripts.
172.It Pa /etc/periodic.conf
173This file contains local overrides for the default
174.Nm
175configuration.
176.El
177.Sh EXAMPLES
178The system crontab should have entries for
179.Nm
180similar to the following example:
181.Bd -literal -offset indent
182# do daily/weekly/monthly maintenance
1830      2       *       *       *       root    periodic daily
1840      3       *       *       6       root    periodic weekly
1850      5       1       *       *       root    periodic monthly
186.Ed
187.Pp
188The
189.Pa /etc/defaults/periodic.conf
190system registry will typically have a
191.Va local_periodic
192variable reading:
193.Pp
194.Dl local_periodic="/usr/local/etc/periodic /usr/X11R6/etc/periodic"
195.Pp
196To log
197.Nm
198output instead of receiving it as email, add the following lines to
199.Pa /etc/periodic.conf :
200.Bd -literal -offset indent
201daily_output=/var/log/daily.log
202weekly_output=/var/log/weekly.log
203monthly_output=/var/log/monthly.log
204.Ed
205.Pp
206To only see important information from daily periodic jobs, add the
207following lines to
208.Pa /etc/periodic.conf :
209.Bd -literal -offset indent
210daily_show_success=NO
211daily_show_info=NO
212daily_show_badconfig=NO
213.Ed
214.Sh SEE ALSO
215.Xr sh 1 ,
216.Xr crontab 5 ,
217.Xr periodic.conf 5 ,
218.Xr cron 8 ,
219.Xr newsyslog 8
220.Sh DIAGNOSTICS
221Exit status is 0 on success and 1 if the command
222fails for one of the following reasons:
223.Bl -diag
224.It usage: periodic <directory of files to execute>
225No directory path argument was passed to
226.Nm
227to specify where the script fragments reside.
228.It <directory> not found
229Self explanatory.
230.El
231.Sh HISTORY
232The
233.Nm
234program first appeared in
235.Fx 3.0 .
236.Sh BUGS
237Since one specifies information about a directory using shell
238variables containing the string,
239.Va <basedir> ,
240.Va <basedir>
241must only contain characters that are valid within a
242.Xr sh 1
243variable name, alphanumerics and underscores, and the first character
244may not be numeric.
245.Sh AUTHORS
246.An Paul Traina Aq pst@FreeBSD.org
247.An Brian Somers Aq brian@Awfulhak.org
248