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