xref: /openbsd-src/share/man/man8/daily.8 (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1.\"	$OpenBSD: daily.8,v 1.24 2016/04/29 13:05:33 schwarze 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: April 29 2016 $
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 .
78.It
79Purges accounting records from
80.Pa /var/account ,
81if they exist.
82See
83.Xr accton 8
84and
85.Xr sa 8 .
86.It
87Creates a backup root file system which is updated daily.
88This only happens if the following conditions are met:
89.Bl -enum -offset indent
90.It
91The environment variable
92.Ev ROOTBACKUP
93must be set.
94For example, the following can be added to
95.Pa /etc/daily.local :
96.Pp
97.Dl ROOTBACKUP=1
98.It
99The mount directory
100.Pa /altroot
101must exist, and there must be an
102.Pa /etc/fstab
103entry specifying a configured disk device, the file system type
104.Sq ffs ,
105and
106.Sq xx
107for the mount options, e.g.
108.Pp
109.Dl /dev/wd0j /altroot ffs xx 0 0
110.El
111.It
112Checks daemon status.
113Lists any daemons which are enabled in
114.Xr rc.conf.local 8
115but which are not actually running.
116.It
117Checks disk status.
118Reports on the amount of disk used/available via
119.Xr df 1 .
120Reports on which file systems need to be dumped via
121.Xr dump 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 makewhatis 8 ,
267.Xr sa 8 ,
268.Xr security 8 ,
269.Xr yp 8
270.Sh HISTORY
271The
272.Nm daily , weekly ,
273and
274.Nm monthly
275scripts first appeared in
276.Bx 4.3 Reno .
277This manual page first appeared in
278.Ox 3.4 .
279.Sh CAVEATS
280If the host machine is not running 24/7, these scripts may never be run.
281Adjusting the time fields in the system
282.Xr crontab 5
283may partially alleviate this problem.
284.Pp
285Be careful when adding local additions.
286Services such as
287.Qq www
288have their own users, and should be run as such, not as root.
289It may be more appropriate to create a separate
290.Xr crontab 5
291for such services.
292