xref: /openbsd/share/man/man8/daily.8 (revision a6445c1d)
1.\"	$OpenBSD: daily.8,v 1.21 2014/07/16 17:03:17 jmc Exp $
2.\"
3.\" Copyright (c) 2003 Jason McIntyre <jmc@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 16 2014 $
18.Dt DAILY 8
19.Os
20.Sh NAME
21.Nm daily , weekly , monthly
22.Nd periodic system maintenance
23.Sh SYNOPSIS
24.Nm /etc/daily
25.Nm /etc/weekly
26.Nm /etc/monthly
27.Sh DESCRIPTION
28The three files
29.Pa /etc/daily ,
30.Pa /etc/weekly ,
31and
32.Pa /etc/monthly
33are shell scripts run on a periodic basis by the clock daemon,
34.Xr cron 8 .
35They take care of some basic administrative tasks.
36Their output, if any, is mailed to root.
37.Pp
38.Sy Note :
39The scripts are all run as part of root's
40.Xr crontab 5 .
41However, it is strongly suggested that the root mail account
42be an alias that forwards messages to a real user or set of users.
43Otherwise, root's mail will simply accumulate in
44.Pa /var/mail
45until the partition holding it runs out of space.
46See
47.Xr newaliases 8
48for further details.
49.Pp
50These scripts should not be altered.
51Local additions should be made to the files
52.Pa /etc/daily.local ,
53.Pa /etc/weekly.local ,
54and
55.Pa /etc/monthly.local ,
56which will be executed by
57.Pa /etc/daily ,
58.Pa /etc/weekly ,
59and
60.Pa /etc/monthly ,
61respectively.
62The
63.Pa *.local
64files are executed first, which makes it convenient to do any necessary
65cleanup and backup and to define any required shell variables before the
66script is run.
67.Ss /etc/daily
68This script is run daily.
69It currently does the following:
70.Bl -dash
71.It
72Runs the script
73.Pa /etc/daily.local ,
74if it exists.
75.It
76Removes scratch and junk files from
77.Pa /tmp
78and
79.Pa /var/tmp .
80.It
81Purges accounting records from
82.Pa /var/account ,
83if they exist.
84See
85.Xr accton 8
86and
87.Xr sa 8 .
88.It
89Creates a backup root file system which is updated daily.
90This only happens if the following conditions are met:
91.Bl -enum -offset indent
92.It
93The environment variable
94.Ev ROOTBACKUP
95must be set.
96For example, the following can be added to
97.Pa /etc/daily.local :
98.Pp
99.Dl ROOTBACKUP=1
100.It
101The mount directory
102.Pa /altroot
103must exist, and there must be an
104.Pa /etc/fstab
105entry specifying a configured disk device, the file system type
106.Sq ffs ,
107and
108.Sq xx
109for the mount options, e.g.
110.Pp
111.Dl /dev/wd0j /altroot ffs xx 0 0
112.El
113.It
114Checks disk status.
115Reports on the amount of disk used/available via
116.Xr df 1 .
117Reports on which file systems need to be dumped via
118.Xr dump 8 .
119.It
120Reports on the status of the mail queue via
121.Xr mailq 8 .
122.It
123Reports networking statistics via
124.Xr netstat 1 .
125.It
126Runs the
127.Xr calendar 1
128utility unless the environment variable
129.Ev CALENDAR
130is set to 0 in
131.Pa /etc/daily.local
132or the host is a
133.Xr yp 8
134client.
135.It
136If
137.Ev CHECKFILESYSTEMS
138is set to 1 in
139.Pa /etc/daily.local ,
140runs
141.Xr fsck 8
142with the no-write flag
143.Pq Fl n .
144.It
145If the file
146.Pa /etc/Distfile
147exists, runs the
148.Xr rdist 1
149utility.
150.It
151Runs the system
152.Xr security 8
153check script.
154.El
155.Ss /etc/weekly
156This script is run weekly.
157It currently does the following:
158.Bl -dash
159.It
160Runs the script
161.Pa /etc/weekly.local ,
162if it exists.
163.It
164Rebuilds the
165.Xr locate 1
166database, if there is an existing
167.Pa /var/db/locate.database
168file.
169.It
170Rebuilds the
171.Xr whatis 1
172database(s) via
173.Xr makewhatis 8 .
174.It
175If
176.Ev LOGINACCOUNTING
177is set to 1 in
178.Pa /etc/weekly.local
179and the
180.Pa /var/log/wtmp
181file exists, show individual users' login via the
182.Xr ac 8
183utility.
184.El
185.Ss /etc/monthly
186This script is run monthly.
187It currently does the following:
188.Bl -dash
189.It
190Runs the script
191.Pa /etc/monthly.local ,
192if it exists.
193.El
194.Sh ENVIRONMENT
195The following variables can be set in
196.Pa /etc/daily.local :
197.Pp
198.Bl -tag -width "CHECKFILESYSTEMS" -compact
199.It Ev CALENDAR
200If set to 0, do not run
201.Xr calendar 1 .
202.It Ev CHECKFILESYSTEMS
203If set to 1, run
204.Xr fsck 8
205with the no-write flag.
206.It Ev ROOTBACKUP
207If set to 1, make a backup of the root file system.
208.It Ev VERBOSESTATUS
209If set to 0,
210.Xr df 1 ,
211.Xr dump 8 ,
212and
213.Xr netstat 1
214are skipped.
215Consequently, if none of the other commands produce any output,
216no mail will be sent to root.
217.El
218.Pp
219The following variables can be set in
220.Pa /etc/weekly.local :
221.Pp
222.Bl -tag -width "CHECKFILESYSTEMS" -compact
223.It Ev LOGINACCOUNTING
224If set to 1, run
225.Xr ac 8
226to report login accounting.
227.It Ev MAKEWHATISARGS
228If set to a string containing at least one character (even a blank),
229use that string as the arguments to
230.Xr makewhatis 8 .
231If unset or empty, use the default argument
232.Fl Q .
233.El
234.Sh FILES
235.Bl -tag -width "/var/cron/tabs/root" -compact
236.It Pa /etc/daily
237Daily maintenance script.
238.It Pa /etc/daily.local
239Site specific daily maintenance script.
240.It Pa /etc/weekly
241Weekly maintenance script.
242.It Pa /etc/weekly.local
243Site specific weekly maintenance script.
244.It Pa /etc/monthly
245Monthly maintenance script.
246.It Pa /etc/monthly.local
247Site specific monthly maintenance script.
248.It Pa /var/cron/tabs/root
249Root
250.Xr crontab 5 .
251.El
252.Sh SEE ALSO
253.Xr calendar 1 ,
254.Xr crontab 1 ,
255.Xr df 1 ,
256.Xr locate 1 ,
257.Xr netstat 1 ,
258.Xr rdist 1 ,
259.Xr whatis 1 ,
260.Xr crontab 5 ,
261.Xr ac 8 ,
262.Xr accton 8 ,
263.Xr cron 8 ,
264.Xr dump 8 ,
265.Xr fsck 8 ,
266.Xr mailq 8 ,
267.Xr makewhatis 8 ,
268.Xr sa 8 ,
269.Xr security 8 ,
270.Xr yp 8
271.Sh HISTORY
272The
273.Nm daily , weekly ,
274and
275.Nm monthly
276scripts first appeared in
277.Bx 4.3 Reno .
278This manual page first appeared in
279.Ox 3.4 .
280.Sh CAVEATS
281If the host machine is not running 24/7, these scripts may never be run.
282Adjusting the time fields in the system
283.Xr crontab 5
284may partially alleviate this problem.
285.Pp
286Be careful when adding local additions.
287Services such as
288.Qq www
289have their own users, and should be run as such, not as root.
290It may be more appropriate to create a separate
291.Xr crontab 5
292for such services.
293