1.\" $OpenBSD: daily.8,v 1.29 2020/10/20 22:42:29 danj 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: October 20 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 117Reports on which file systems need to be dumped via 118.Xr dump 8 . 119.It 120Runs the 121.Xr calendar 1 122utility unless the environment variable 123.Ev CALENDAR 124is set to 0 in 125.Pa /etc/daily.local 126or the host is a 127.Xr yp 8 128client. 129.It 130If 131.Ev CHECKFILESYSTEMS 132is set to 1 in 133.Pa /etc/daily.local , 134runs 135.Xr fsck 8 136with the no-write flag 137.Pq Fl n . 138.It 139If the file 140.Pa /etc/Distfile 141exists, runs the 142.Xr rdist 1 143utility. 144.It 145Runs the system 146.Xr security 8 147check script. 148.El 149.Ss /etc/weekly 150This script is run weekly. 151It currently does the following: 152.Bl -dash 153.It 154Runs the script 155.Pa /etc/weekly.local , 156if it exists. 157.It 158Rebuilds the 159.Xr locate 1 160database, if there is an existing 161.Pa /var/db/locate.database 162file. 163.It 164Rebuilds the 165.Xr whatis 1 166database(s) via 167.Xr makewhatis 8 . 168.It 169If 170.Ev LOGINACCOUNTING 171is set to 1 in 172.Pa /etc/weekly.local 173and the 174.Pa /var/log/wtmp 175file exists, show individual users' login via the 176.Xr ac 8 177utility. 178.El 179.Ss /etc/monthly 180This script is run monthly. 181It currently does the following: 182.Bl -dash 183.It 184Runs the script 185.Pa /etc/monthly.local , 186if it exists. 187.El 188.Sh ENVIRONMENT 189The following variables can be set in 190.Pa /etc/daily.local : 191.Pp 192.Bl -tag -width "CHECKFILESYSTEMS" -compact 193.It Ev CALENDAR 194If set to 0, do not run 195.Xr calendar 1 . 196.It Ev CHECKFILESYSTEMS 197If set to 1, run 198.Xr fsck 8 199with the no-write flag. 200.It Ev ROOTBACKUP 201If set to 1, make a backup of the root file system. 202.El 203.Pp 204The following variables can be set in 205.Pa /etc/weekly.local : 206.Pp 207.Bl -tag -width "CHECKFILESYSTEMS" -compact 208.It Ev LOGINACCOUNTING 209If set to 1, run 210.Xr ac 8 211to report login accounting. 212.It Ev MAKEWHATISARGS 213Arguments for 214.Xr makewhatis 8 ; 215empty by default. 216.El 217.Sh FILES 218.Bl -tag -width "/var/cron/tabs/root" -compact 219.It Pa /etc/daily 220Daily maintenance script. 221.It Pa /etc/daily.local 222Site specific daily maintenance script. 223.It Pa /etc/weekly 224Weekly maintenance script. 225.It Pa /etc/weekly.local 226Site specific weekly maintenance script. 227.It Pa /etc/monthly 228Monthly maintenance script. 229.It Pa /etc/monthly.local 230Site specific monthly maintenance script. 231.It Pa /var/cron/tabs/root 232Root 233.Xr crontab 5 . 234.El 235.Sh SEE ALSO 236.Xr calendar 1 , 237.Xr crontab 1 , 238.Xr locate 1 , 239.Xr rdist 1 , 240.Xr whatis 1 , 241.Xr crontab 5 , 242.Xr ac 8 , 243.Xr accton 8 , 244.Xr cron 8 , 245.Xr dump 8 , 246.Xr fsck 8 , 247.Xr makewhatis 8 , 248.Xr sa 8 , 249.Xr security 8 , 250.Xr yp 8 251.Sh HISTORY 252The 253.Nm daily , weekly , 254and 255.Nm monthly 256scripts first appeared in 257.Bx 4.3 Reno . 258This manual page first appeared in 259.Ox 3.4 . 260.Sh CAVEATS 261If the host machine is not running 24/7, these scripts may never be run. 262Adjusting the time fields in the system 263.Xr crontab 5 264may partially alleviate this problem. 265.Pp 266Be careful when adding local additions. 267Services such as 268.Qq www 269have their own users, and should be run as such, not as root. 270It may be more appropriate to create a separate 271.Xr crontab 5 272for such services. 273