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