xref: /openbsd/share/man/man8/daily.8 (revision 09467b48)
1.\"	$OpenBSD: daily.8,v 1.28 2020/07/26 13:27:24 rob 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 26 2020 $
18.Dt DAILY 8
19.Os
20.Sh NAME
21.Nm daily , weekly , monthly
22.Nd periodic system maintenance
23.Sh DESCRIPTION
24The three files
25.Pa /etc/daily ,
26.Pa /etc/weekly ,
27and
28.Pa /etc/monthly
29are shell scripts run on a periodic basis by the clock daemon,
30.Xr cron 8 .
31They take care of some basic administrative tasks.
32Their output, if any, is mailed to root.
33.Pp
34.Sy Note :
35The scripts are all run as part of root's
36.Xr crontab 5 .
37However, it is strongly suggested that the root mail account
38be an alias that forwards messages to a real user or set of users.
39Otherwise, root's mail will simply accumulate in
40.Pa /var/mail
41until the partition holding it runs out of space.
42See
43.Xr newaliases 8
44for further details.
45.Pp
46These scripts should not be altered.
47Local additions should be made to the files
48.Pa /etc/daily.local ,
49.Pa /etc/weekly.local ,
50and
51.Pa /etc/monthly.local ,
52which will be executed by
53.Pa /etc/daily ,
54.Pa /etc/weekly ,
55and
56.Pa /etc/monthly ,
57respectively.
58The
59.Pa *.local
60files are executed first, which makes it convenient to do any necessary
61cleanup and backup and to define any required shell variables before the
62script is run.
63.Ss /etc/daily
64This script is run daily.
65It currently does the following:
66.Bl -dash
67.It
68Runs the script
69.Pa /etc/daily.local ,
70if it exists.
71.It
72Removes scratch and junk files from
73.Pa /tmp .
74.It
75Purges accounting records from
76.Pa /var/account ,
77if they exist.
78Processes that were killed due to pledge or memory access violations,
79or had file access prevented by unveil,
80are reported in the daily mail.
81See
82.Xr accton 8 ,
83.Xr lastcomm 1 ,
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
228Arguments for
229.Xr makewhatis 8 ;
230empty by default.
231.El
232.Sh FILES
233.Bl -tag -width "/var/cron/tabs/root" -compact
234.It Pa /etc/daily
235Daily maintenance script.
236.It Pa /etc/daily.local
237Site specific daily maintenance script.
238.It Pa /etc/weekly
239Weekly maintenance script.
240.It Pa /etc/weekly.local
241Site specific weekly maintenance script.
242.It Pa /etc/monthly
243Monthly maintenance script.
244.It Pa /etc/monthly.local
245Site specific monthly maintenance script.
246.It Pa /var/cron/tabs/root
247Root
248.Xr crontab 5 .
249.El
250.Sh SEE ALSO
251.Xr calendar 1 ,
252.Xr crontab 1 ,
253.Xr df 1 ,
254.Xr locate 1 ,
255.Xr netstat 1 ,
256.Xr rdist 1 ,
257.Xr whatis 1 ,
258.Xr crontab 5 ,
259.Xr ac 8 ,
260.Xr accton 8 ,
261.Xr cron 8 ,
262.Xr dump 8 ,
263.Xr fsck 8 ,
264.Xr makewhatis 8 ,
265.Xr sa 8 ,
266.Xr security 8 ,
267.Xr yp 8
268.Sh HISTORY
269The
270.Nm daily , weekly ,
271and
272.Nm monthly
273scripts first appeared in
274.Bx 4.3 Reno .
275This manual page first appeared in
276.Ox 3.4 .
277.Sh CAVEATS
278If the host machine is not running 24/7, these scripts may never be run.
279Adjusting the time fields in the system
280.Xr crontab 5
281may partially alleviate this problem.
282.Pp
283Be careful when adding local additions.
284Services such as
285.Qq www
286have their own users, and should be run as such, not as root.
287It may be more appropriate to create a separate
288.Xr crontab 5
289for such services.
290