xref: /freebsd/usr.sbin/periodic/periodic.8 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1c0fa6e33SPaul Traina.\" Copyright (c) 1997 FreeBSD, Inc.
2c0fa6e33SPaul Traina.\" All rights reserved.
3c0fa6e33SPaul Traina.\"
4c0fa6e33SPaul Traina.\" Redistribution and use in source and binary forms, with or without
5c0fa6e33SPaul Traina.\" modification, are permitted provided that the following conditions
6c0fa6e33SPaul Traina.\" are met:
7c0fa6e33SPaul Traina.\" 1. Redistributions of source code must retain the above copyright
8c0fa6e33SPaul Traina.\"    notice, this list of conditions and the following disclaimer.
9c0fa6e33SPaul Traina.\" 2. Redistributions in binary form must reproduce the above copyright
10c0fa6e33SPaul Traina.\"    notice, this list of conditions and the following disclaimer in the
11c0fa6e33SPaul Traina.\"    documentation and/or other materials provided with the distribution.
12c0fa6e33SPaul Traina.\"
13c0fa6e33SPaul Traina.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14c0fa6e33SPaul Traina.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15c0fa6e33SPaul Traina.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16c0fa6e33SPaul Traina.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17c0fa6e33SPaul Traina.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18c0fa6e33SPaul Traina.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19c0fa6e33SPaul Traina.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20c0fa6e33SPaul Traina.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21c0fa6e33SPaul Traina.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22c0fa6e33SPaul Traina.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23c0fa6e33SPaul Traina.\" SUCH DAMAGE.
24c0fa6e33SPaul Traina.\"
25aa1f87cbSMateusz Piotrowski.Dd June 18, 2020
26696a50cdSAndrey A. Chernov.Dt PERIODIC 8
27aa12cea2SUlrich Spörlein.Os
28c0fa6e33SPaul Traina.Sh NAME
29c0fa6e33SPaul Traina.Nm periodic
30eb083802SRuslan Ermilov.Nd run periodic system functions
31c0fa6e33SPaul Traina.Sh SYNOPSIS
32e97407b4SRuslan Ermilov.Nm
33aa1f87cbSMateusz Piotrowski.Sm off
34aa1f87cbSMateusz Piotrowski.Cm daily | weekly | monthly | security | Ar directory
35aa1f87cbSMateusz Piotrowski.Sm on
36aa1f87cbSMateusz Piotrowski.Ar ...
37c0fa6e33SPaul Traina.Sh DESCRIPTION
38c0fa6e33SPaul TrainaThe
39c0fa6e33SPaul Traina.Nm
40490d5836SPhilippe Charnierutility is intended to be called by
416575e6daSRuslan Ermilov.Xr cron 8
426575e6daSRuslan Ermilovto execute shell scripts
43c0fa6e33SPaul Trainalocated in the specified directory.
44c0fa6e33SPaul Traina.Pp
459ed55d11SBrian SomersOne or more of the following arguments must be specified:
46aa1f87cbSMateusz Piotrowski.Bl -tag -width "directory"
47aa1f87cbSMateusz Piotrowski.It Cm daily
48fb1485d3SPaul TrainaPerform the standard daily periodic executable run.
49fb1485d3SPaul TrainaThis usually occurs early in the morning (local time).
50aa1f87cbSMateusz Piotrowski.It Cm weekly
51fb1485d3SPaul TrainaPerform the standard weekly periodic executable run.
527c34436eSGabor KovesdanThis usually occurs very early on Saturday mornings.
53aa1f87cbSMateusz Piotrowski.It Cm monthly
54fb1485d3SPaul TrainaPerform the standard monthly periodic executable run.
55fb1485d3SPaul TrainaThis usually occurs on the first day of the month.
56aa1f87cbSMateusz Piotrowski.It Cm security
572204f3ceSCrist J. ClarkPerform the standard daily security checks.
582204f3ceSCrist J. ClarkThis is usually spawned by the
59aa1f87cbSMateusz Piotrowski.Cm daily
602204f3ceSCrist J. Clarkrun.
61aa1f87cbSMateusz Piotrowski.It Ar directory
629ed55d11SBrian SomersAn arbitrary directory containing a set of executables to be run.
63c0fa6e33SPaul Traina.El
64fb1485d3SPaul Traina.Pp
659ed55d11SBrian SomersIf an argument is an absolute directory name it is used as is, otherwise
669ed55d11SBrian Somersit is searched for under
679ed55d11SBrian Somers.Pa /etc/periodic
689ed55d11SBrian Somersand any other directories specified by the
699ed55d11SBrian Somers.Va local_periodic
709ed55d11SBrian Somerssetting in
719ed55d11SBrian Somers.Xr periodic.conf 5
729ed55d11SBrian Somers(see below).
739ed55d11SBrian Somers.Pp
74fb1485d3SPaul TrainaThe
75fb1485d3SPaul Traina.Nm
76490d5836SPhilippe Charnierutility will run each executable file in the directory or directories
779ed55d11SBrian Somersspecified.
789ed55d11SBrian SomersIf a file does not have the executable bit set, it is silently ignored.
799ed55d11SBrian Somers.Pp
809ed55d11SBrian SomersEach script is required to exit with one of the following values:
815849041bSRuslan Ermilov.Bl -tag -width 4n
829ed55d11SBrian Somers.It 0
835e75e35cSDima DorfmanThe script has produced nothing notable in its output.
849ed55d11SBrian SomersThe
855849041bSRuslan Ermilov.Ao Ar basedir Ac Ns Va _show_success
869ed55d11SBrian Somersvariable controls the masking of this output.
879ed55d11SBrian Somers.It 1
885e75e35cSDima DorfmanThe script has produced some notable information in its output.
899ed55d11SBrian SomersThe
905849041bSRuslan Ermilov.Ao Ar basedir Ac Ns Va _show_info
919ed55d11SBrian Somersvariable controls the masking of this output.
929ed55d11SBrian Somers.It 2
939ed55d11SBrian SomersThe script has produced some warnings due to invalid configuration settings.
949ed55d11SBrian SomersThe
955849041bSRuslan Ermilov.Ao Ar basedir Ac Ns Va _show_badconfig
969ed55d11SBrian Somersvariable controls the masking of this output.
979ed55d11SBrian Somers.It >2
989ed55d11SBrian SomersThe script has produced output that must not be masked.
999ed55d11SBrian Somers.El
1009ed55d11SBrian Somers.Pp
1019ed55d11SBrian SomersIf the relevant variable (where
1025849041bSRuslan Ermilov.Aq Ar basedir
1039ed55d11SBrian Somersis the base directory in which the script resides) is set to
1045849041bSRuslan Ermilov.Dq Li NO
1059ed55d11SBrian Somersin
1069ed55d11SBrian Somers.Pa periodic.conf ,
1079ed55d11SBrian Somers.Nm
1089ed55d11SBrian Somerswill mask the script output.
1099ed55d11SBrian SomersIf the variable is not set to either
1105849041bSRuslan Ermilov.Dq Li YES
1119ed55d11SBrian Somersor
1125849041bSRuslan Ermilov.Dq Li NO ,
1139ed55d11SBrian Somersit will be given a default value as described in
1149ed55d11SBrian Somers.Xr periodic.conf 5 .
1159ed55d11SBrian Somers.Pp
1169ed55d11SBrian SomersAll remaining script output is delivered based on the value of the
1175849041bSRuslan Ermilov.Ao Ar basedir Ac Ns Va _output
1189ed55d11SBrian Somerssetting.
1199ed55d11SBrian Somers.Pp
1209ed55d11SBrian SomersIf this is set to a path name (beginning with a
1215849041bSRuslan Ermilov.Ql /
1225849041bSRuslan Ermilovcharacter), output is simply logged to that file.
1239ed55d11SBrian Somers.Xr newsyslog 8
1249ed55d11SBrian Somersknows about the files
1255849041bSRuslan Ermilov.Pa /var/log/daily.log , /var/log/weekly.log
1269ed55d11SBrian Somersand
1279ed55d11SBrian Somers.Pa /var/log/monthly.log ,
1289ed55d11SBrian Somersand if they exist, it will rotate them at the appropriate times.
1299ed55d11SBrian SomersThese are therefore good values if you wish to log
1309ed55d11SBrian Somers.Nm
1319ed55d11SBrian Somersoutput.
1329ed55d11SBrian Somers.Pp
1339ed55d11SBrian SomersIf the
1345849041bSRuslan Ermilov.Ao Ar basedir Ac Ns Va _output
1359ed55d11SBrian Somersvalue does not begin with a
1365849041bSRuslan Ermilov.Ql /
137df470af5SBrian Somersand is not empty, it is assumed to contain a list of email addresses, and
138df470af5SBrian Somersthe output is mailed to them.
13968c35072SDavid MaloneIf
14068c35072SDavid Malone.Ao Ar basedir Ac Ns Va _show_empty_output
14168c35072SDavid Maloneis set to
14268c35072SDavid Malone.Dq Li NO ,
14368c35072SDavid Malonethen no mail will be sent if the output was empty.
1449ed55d11SBrian Somers.Pp
1459ed55d11SBrian SomersIf
1465849041bSRuslan Ermilov.Ao Ar basedir Ac Ns Va _output
147df470af5SBrian Somersis not set or is empty, output is sent to standard output.
148c0fa6e33SPaul Traina.Sh ENVIRONMENT
149c0fa6e33SPaul TrainaThe
150c0fa6e33SPaul Traina.Nm
151490d5836SPhilippe Charnierutility sets the
152c0fa6e33SPaul Traina.Ev PATH
153fb1485d3SPaul Trainaenvironment to include all standard system directories, but no additional
154fb1485d3SPaul Trainadirectories, such as
155fb1485d3SPaul Traina.Pa /usr/local/bin .
156fb1485d3SPaul TrainaIf executables are added which depend upon other path components, each
157fb1485d3SPaul Trainaexecutable must be responsible for configuring its own appropriate environment.
158c0fa6e33SPaul Traina.Sh FILES
159490d5836SPhilippe Charnier.Bl -tag -width ".Pa /etc/defaults/periodic.conf"
160c0fa6e33SPaul Traina.It Pa /etc/crontab
161490d5836SPhilippe Charnierthe
162c0fa6e33SPaul Traina.Nm
163490d5836SPhilippe Charnierutility is typically called via entries in the system default
1645849041bSRuslan Ermilov.Xr cron 8
165490d5836SPhilippe Charniertable
1662a13325fSPaul Traina.It Pa /etc/periodic
167490d5836SPhilippe Charnierthe top level directory containing
168fb1485d3SPaul Traina.Pa daily ,
169fb1485d3SPaul Traina.Pa weekly ,
170c5b5b50dSAlan Somers.Pa monthly ,
171fb1485d3SPaul Trainaand
172c5b5b50dSAlan Somers.Pa security
173490d5836SPhilippe Charniersubdirectories which contain standard system periodic executables
174f3e285baSBrian Somers.It Pa /etc/defaults/periodic.conf
175490d5836SPhilippe Charnierthe
176f3e285baSBrian Somers.Pa periodic.conf
1779ed55d11SBrian Somerssystem registry contains variables that control the behaviour of
1789ed55d11SBrian Somers.Nm
1799ed55d11SBrian Somersand the standard
180c5b5b50dSAlan Somers.Pa daily , weekly , monthly ,
181fb1485d3SPaul Trainaand
182c5b5b50dSAlan Somers.Pa security
183490d5836SPhilippe Charnierscripts
184*e5d7100cSJuraj Lutter.It Pa /etc/periodic.conf , ${LOCALBASE}/etc/periodic.conf
185490d5836SPhilippe Charnierthis file contains local overrides for the default
1865849041bSRuslan Ermilov.Nm
187490d5836SPhilippe Charnierconfiguration
188c0fa6e33SPaul Traina.El
18959a3c79dSRuslan Ermilov.Sh EXIT STATUS
19059a3c79dSRuslan ErmilovExit status is 0 on success and 1 if the command fails.
191c0fa6e33SPaul Traina.Sh EXAMPLES
192c0fa6e33SPaul TrainaThe system crontab should have entries for
193c0fa6e33SPaul Traina.Nm
194c0fa6e33SPaul Trainasimilar to the following example:
1955849041bSRuslan Ermilov.Bd -literal -offset indent
1965849041bSRuslan Ermilov# do daily/weekly/monthly maintenance
1975849041bSRuslan Ermilov0      2       *       *       *       root    periodic daily
1985849041bSRuslan Ermilov0      3       *       *       6       root    periodic weekly
1995849041bSRuslan Ermilov0      5       1       *       *       root    periodic monthly
2005849041bSRuslan Ermilov.Ed
201fb1485d3SPaul Traina.Pp
2029ed55d11SBrian SomersThe
203f3e285baSBrian Somers.Pa /etc/defaults/periodic.conf
204f3e285baSBrian Somerssystem registry will typically have a
205f8c6d853SGuy Helmer.Va local_periodic
206fb1485d3SPaul Trainavariable reading:
207f3e285baSBrian Somers.Pp
208*e5d7100cSJuraj Lutter.Dl local_periodic="${_localbase}/etc/periodic"
209*e5d7100cSJuraj Lutter.Pp
210*e5d7100cSJuraj Lutterwhere
211*e5d7100cSJuraj Lutter.Pa ${_localbase}
212*e5d7100cSJuraj Lutteris being set from within
213*e5d7100cSJuraj Lutter.Pa /usr/sbin/periodic .
2149ed55d11SBrian Somers.Pp
2159ed55d11SBrian SomersTo log
2169ed55d11SBrian Somers.Nm
2179ed55d11SBrian Somersoutput instead of receiving it as email, add the following lines to
2189ed55d11SBrian Somers.Pa /etc/periodic.conf :
2195849041bSRuslan Ermilov.Bd -literal -offset indent
2205849041bSRuslan Ermilovdaily_output=/var/log/daily.log
2215849041bSRuslan Ermilovweekly_output=/var/log/weekly.log
2225849041bSRuslan Ermilovmonthly_output=/var/log/monthly.log
2235849041bSRuslan Ermilov.Ed
2249ed55d11SBrian Somers.Pp
2259ed55d11SBrian SomersTo only see important information from daily periodic jobs, add the
2269ed55d11SBrian Somersfollowing lines to
2279ed55d11SBrian Somers.Pa /etc/periodic.conf :
2285849041bSRuslan Ermilov.Bd -literal -offset indent
2295849041bSRuslan Ermilovdaily_show_success=NO
2305849041bSRuslan Ermilovdaily_show_info=NO
2315849041bSRuslan Ermilovdaily_show_badconfig=NO
2325849041bSRuslan Ermilov.Ed
233c0fa6e33SPaul Traina.Sh DIAGNOSTICS
234a866e170SRuslan ErmilovThe command may fail for one of the following reasons:
235c0fa6e33SPaul Traina.Bl -diag
236c0fa6e33SPaul Traina.It usage: periodic <directory of files to execute>
237c0fa6e33SPaul TrainaNo directory path argument was passed to
238c0fa6e33SPaul Traina.Nm
239c0fa6e33SPaul Trainato specify where the script fragments reside.
240c0fa6e33SPaul Traina.It <directory> not found
241c0fa6e33SPaul TrainaSelf explanatory.
242c0fa6e33SPaul Traina.El
24359a3c79dSRuslan Ermilov.Sh SEE ALSO
24459a3c79dSRuslan Ermilov.Xr sh 1 ,
24559a3c79dSRuslan Ermilov.Xr crontab 5 ,
24659a3c79dSRuslan Ermilov.Xr periodic.conf 5 ,
24759a3c79dSRuslan Ermilov.Xr cron 8 ,
24859a3c79dSRuslan Ermilov.Xr newsyslog 8
249c0fa6e33SPaul Traina.Sh HISTORY
250c0fa6e33SPaul TrainaThe
251c0fa6e33SPaul Traina.Nm
252490d5836SPhilippe Charnierutility first appeared in
253c0fa6e33SPaul Traina.Fx 3.0 .
25459a3c79dSRuslan Ermilov.Sh AUTHORS
25501c2b8acSBaptiste Daroussin.An Paul Traina Aq Mt pst@FreeBSD.org
25601c2b8acSBaptiste Daroussin.An Brian Somers Aq Mt brian@Awfulhak.org
257a4771d5fSCrist J. Clark.Sh BUGS
258a4771d5fSCrist J. ClarkSince one specifies information about a directory using shell
259a4771d5fSCrist J. Clarkvariables containing the string,
260c9d99fb5SRuslan Ermilov.Aq Ar basedir ,
261c9d99fb5SRuslan Ermilov.Aq Ar basedir
262a4771d5fSCrist J. Clarkmust only contain characters that are valid within a
263a4771d5fSCrist J. Clark.Xr sh 1
264a4771d5fSCrist J. Clarkvariable name, alphanumerics and underscores, and the first character
265a4771d5fSCrist J. Clarkmay not be numeric.
266