xref: /openbsd-src/share/man/man8/daily.8 (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1.\"	$OpenBSD: daily.8,v 1.18 2011/04/18 23:58:45 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 18 2011 $
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
81Removes stale files from the
82.Xr rwhod 8
83database.
84.It
85Purges accounting records from
86.Pa /var/account ,
87if they exist.
88See
89.Xr accton 8
90and
91.Xr sa 8 .
92.It
93Creates a backup root file system which is updated daily.
94This only happens if the following conditions are met:
95.Bl -enum -offset indent
96.It
97The environment variable
98.Ev ROOTBACKUP
99must be set.
100For example, the following can be added to
101.Pa /etc/daily.local :
102.Pp
103.Dl ROOTBACKUP=1
104.It
105The mount directory
106.Pa /altroot
107must exist, and there must be an
108.Pa /etc/fstab
109entry specifying a configured disk device, the file system type
110.Sq ffs ,
111and
112.Sq xx
113for the mount options, e.g.
114.Pp
115.Dl /dev/wd0j /altroot ffs xx 0 0
116.El
117.It
118Checks disk status.
119Reports on the amount of disk used/available via
120.Xr df 1 .
121Reports on which file systems need to be dumped via
122.Xr dump 8 .
123.It
124Reports on the status of the mail queue via
125.Xr mailq 8 .
126.It
127Reports networking statistics via
128.Xr netstat 1 .
129.It
130Gives an uptime for every machine which exists in
131.Pa /var/rwho ,
132via the
133.Xr ruptime 1
134utility.
135.It
136Runs the
137.Xr calendar 1
138utility unless the environment variable
139.Ev CALENDAR
140is set to 0 in
141.Pa /etc/daily.local
142or the host is a
143.Xr yp 8
144client.
145.It
146If
147.Ev CHECKFILESYSTEMS
148is set to 1 in
149.Pa /etc/daily.local ,
150runs
151.Xr fsck 8
152with the no-write flag
153.Pq Fl n .
154.It
155If the file
156.Pa /etc/Distfile
157exists, runs the
158.Xr rdist 1
159utility.
160.It
161Runs the system
162.Xr security 8
163check script.
164.El
165.Ss /etc/weekly
166This script is run weekly.
167It currently does the following:
168.Bl -dash
169.It
170Runs the script
171.Pa /etc/weekly.local ,
172if it exists.
173.It
174Rebuilds the
175.Xr locate 1
176database, if there is an existing
177.Pa /var/db/locate.database
178file.
179.It
180Rebuilds the
181.Xr whatis 1
182database(s) via
183.Xr makewhatis 8 .
184.It
185If
186.Ev LOGINACCOUNTING
187is set to 1 in
188.Pa /etc/weekly.local
189and the
190.Pa /var/log/wtmp
191file exists, show individual users' login via the
192.Xr ac 8
193utility.
194.El
195.Ss /etc/monthly
196This script is run monthly.
197It currently does the following:
198.Bl -dash
199.It
200Runs the script
201.Pa /etc/monthly.local ,
202if it exists.
203.El
204.Sh ENVIRONMENT
205The following variables can be set in
206.Pa /etc/daily.local :
207.Pp
208.Bl -tag -width "CHECKFILESYSTEMS" -compact
209.It Ev CALENDAR
210If set to 1, run
211.Xr calendar 1 .
212.It Ev CHECKFILESYSTEMS
213If set to 1, run
214.Xr fsck 8
215with the no-write flag.
216.It Ev ROOTBACKUP
217If set to 1, make a backup of the root file system.
218.It Ev VERBOSESTATUS
219If set to 0,
220.Xr df 1 ,
221.Xr dump 8 ,
222.Xr netstat 1 ,
223and
224.Xr ruptime 1
225are skipped.
226Consequently, if none of the other commands produce any output,
227no mail will be sent to root.
228.El
229.Pp
230The following variables can be set in
231.Pa /etc/weekly.local :
232.Pp
233.Bl -tag -width "CHECKFILESYSTEMS" -compact
234.It Ev LOGINACCOUNTING
235If set to 1, run
236.Xr ac 8
237to report login accounting.
238.El
239.Sh FILES
240.Bl -tag -width "/var/cron/tabs/root" -compact
241.It Pa /etc/daily
242Daily maintenance script.
243.It Pa /etc/daily.local
244Site specific daily maintenance script.
245.It Pa /etc/weekly
246Weekly maintenance script.
247.It Pa /etc/weekly.local
248Site specific weekly maintenance script.
249.It Pa /etc/monthly
250Monthly maintenance script.
251.It Pa /etc/monthly.local
252Site specific monthly maintenance script.
253.It Pa /var/cron/tabs/root
254Root
255.Xr crontab 5 .
256.El
257.Sh SEE ALSO
258.Xr calendar 1 ,
259.Xr crontab 1 ,
260.Xr df 1 ,
261.Xr locate 1 ,
262.Xr netstat 1 ,
263.Xr rdist 1 ,
264.Xr ruptime 1 ,
265.Xr rwho 1 ,
266.Xr whatis 1 ,
267.Xr crontab 5 ,
268.Xr ac 8 ,
269.Xr accton 8 ,
270.Xr cron 8 ,
271.Xr dump 8 ,
272.Xr fsck 8 ,
273.Xr mailq 8 ,
274.Xr makewhatis 8 ,
275.Xr sa 8 ,
276.Xr security 8 ,
277.Xr yp 8
278.Sh HISTORY
279The
280.Nm daily , weekly ,
281and
282.Nm monthly
283scripts first appeared in
284.Bx 4.3 Reno .
285This manual page first appeared in
286.Ox 3.4 .
287.Sh CAVEATS
288If the host machine is not running 24/7, these scripts may never be run.
289Adjusting the time fields in the system
290.Xr crontab 5
291may partially alleviate this problem.
292.Pp
293Be careful when adding local additions.
294Services such as
295.Qq www
296have their own users, and should be run as such, not as root.
297It may be more appropriate to create a separate
298.Xr crontab 5
299for such services.
300