diff --git a/share/man/man5/periodic.conf.5 b/share/man/man5/periodic.conf.5 index 5e085d78e497..dec97172e9c8 100644 --- a/share/man/man5/periodic.conf.5 +++ b/share/man/man5/periodic.conf.5 @@ -1,515 +1,514 @@ .\"- .\" Copyright (c) 2000 Brian Somers .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd June 22, 2000 .Dt PERIODIC.CONF 5 .Os FreeBSD 5.0 .Sh NAME .Nm periodic.conf .Nd periodic job configuration information. .Sh DESCRIPTION The file .Nm periodic.conf contains a description of how daily, weekly and montly system maintenance jobs should run. It resides in the .Pa /etc/defaults directory and parts may be overridden by a file of the same name in .Pa /etc , which itself may be overridden by the .Pa /etc/periodic.conf.local file. .Pp .Nm is actually sourced as a shell script from each of the periodic scripts and is intended to simply provide default configuration variables. .Pp The following variables are used by .Xr periodic 8 itself: .Bl -tag -offset 4n -width 2n .It Ar local_periodic (str) List of directories to search for periodic scripts. This list is always prefixed with .Pa /etc/periodic , and is only used when an argument to .Xr periodic 8 is not an absolute directory name. .It Ar dir Ns No _output (path or list) What to do with the output of the scripts envoked from the directory .Ar dir . If this variable is set to an absolute path name, output is logged to that file, otherwise it is taken as one or more space seperated email addresses and mailed to those users. -If this variable is not set, it defaults to -.Dq root . +If this variable is not set or is empty, output is sent to standard output. .Pp For an unattended machine, suitable values for .Ar $daily_output , .Ar $weekly_output , and .Ar $monthly_output might be .Dq /var/log/daily.log , .Dq /var/log/weekly.log , and .Dq /var/log/monthly.log respectively, as .Xr newsyslog 8 will rotate these files (if they exists) at the appropriate times. .It Ar dir Ns No _show_success .It Ar dir Ns No _show_info .It Ar dir Ns No _show_badconfig (bool) These variables control whether .Xr periodic 8 will mask the output of the envoked scripts based on their return code (where .Ar dir is the base directory name in which each script resides). If the return code of a script is .Sq 0 and .Ar dir Ns No _show_success is set to .Dq NO , .Xr periodic 8 will mask the script's output. If the return code of a script is .Sq 1 and .Ar dir Ns No _show_info is set to .Dq NO , .Xr periodic 8 will mask the script's output. If the return code of a script is .Sq 2 and .Ar dir Ns No _show_badconfig is set to .Dq NO , .Xr periodic 8 will mask the script's output. If these variables are set to neither .Dq YES nor .Dq NO , the default to .Dq YES , .Dq YES and .Dq NO respectively. .Pp Refer to the .Xr periodic 8 man page for how script return codes are interpreted. .El .B Daily variables .Pp The following variables are used by the standard scripts that reside in .Pa /etc/periodic/daily : .Bl -tag -offset 4n -width 2n .It Ar daily_clean_disks_enable (bool) Set to .Dq YES if you want to remove all files matching .Ar daily_clean_disks_files daily. .It Ar daily_clean_disks_files (str) Set to a list of file names to match. Wild cards are permitted. .It Ar daily_clean_disks_days (int) When .Ar daily_clean_disks_enable is set to .Dq YES , this must also be set to the number of days old that a file's access and modification times must be before it's deleted. .It Ar daily_clean_disks_verbose (bool) Set to .Dq YES if you want the removed files to be reported in your daily output. .It Ar daily_clean_tmps_enable (bool) Set to .Dq YES if you want to clear temporary directories daily. .It Ar daily_clean_tmps_dirs (str) Set to the list of directories to clear if .Ar daily_clean_tmps_enable is set to .Dq YES . .It Ar daily_clean_tmps_days (int) When .Ar daily_clean_tmps_enable is set, this must also be set to the number of days old that a file's access and modification times must be before it's deleted. .It Ar daily_clean_tmps_ignore (str) Set to the list of files that should not be deleted when .Ar daily_clean_tmps_enable is set to .Dq YES . Wild card characters are permitted. .It Ar daily_clean_tmps_verbose (bool) Set to .Dq YES if you want the removed files to be reported in your daily output. .It Ar daily_clean_preserve_enable (bool) Set to .Dq YES if you wish to remove old files from .Pa /var/preserve . .It Ar daily_clean_preserve_days (num) Set to the number of days that files must not have been modified before they are deleted. .It Ar daily_clean_preserve_verbose (bool) Set to .Dq YES if you want the removed files to be reported in your daily output. .It Ar daily_clean_msgs_enable (bool) Set to .Dq YES if you old system messages to be purged. .It Ar daily_clean_msgs_days (num) Set to the number of days that files must not have been modified before they are deleted. If this variable is left blank, the .Xr msgs 1 default is used. .It Ar daily_clean_rwho_enable (bool) Set to .Dq YES if you wish old files in .Pa /var/who to be purged. .It Ar daily_clean_rwho_days (num) Set to the number of days that files must not have been modified before they are deleted. .It Ar daily_clean_rwho_verbose (bool) Set to .Dq YES if you want the removed files to be reported in your daily output. .It Ar daily_clean_hoststat_enable (bool) Set to .Dq YES if you wish old files in .Pa /var/spool/.hoststat to be purged. .It Ar daily_clean_hoststat_days (num) Set to the number of days that files must not have been modified before they are deleted. .It Ar daily_clean_hoststat_verbose (bool) Set to .Dq YES if you want the removed files to be reported in your daily output. .It Ar daily_backup_passwd_enable (bool) Set to .Dq YES if you want the .Pa /etc/master.passwd and .Pa /etc/group files backed up and reported on. Reporting consists of checking both files for modifications and running .Xr chkgrp 8 on the .Pa group file. .It Ar daily_backup_aliases_enable (bool) Set to .Dq YES if you want the .Pa /etc/mail/aliases file backed up and modifications to be displayed in your daily output. .It Ar daily_backup_distfile_enable (bool) Set to .Dq YES if you want the .Pa /etc/Distfile file backed up and modifications to be displayed in your daily output. .It Ar daily_calendar_enable (bool) Set to .Dq YES if you want to run .Ic calendar -a daily. .It Ar daily_accounting_enable (bool) Set to .Dq YES if you want to rotate your daily accounting files. No rotations are necessary unless .Ar accounting_enable is enabled in .Xr rc.conf 5 . .It Ar daily_accounting_compress (bool) Set to .Dq YES if you want your daily accounting files to be compressed using .Xr gzip 1 . .It Ar daily_distfile_enable (bool) Set to .Dq YES if you want to run .Xr rdist 1 daily. The .Pa /etc/Distfile file must also exist. .It Pa daily_news_expire_enable (bool) Set to .Dq YES if you want to run .Pa /etc/news.expire . .It Pa daily_uuclean_enable (bool) Set to .Dq YES if you want to run .Pa /etc/uuclean.daily . .It Ar daily_status_disks_enable (bool) Set to .Dq YES if you want to run .Xr df 1 .Po with the arguments supplied in .Ar daily_status_disks_df_flags .Pc and .Ic dump W . .It Ar daily_status_disks_df_flags (str) Set to the arguments for the .Xr df 1 utility when .Ar daily_status_disks_enable is set to .Dq YES . .It Ar daily_status_uucp_enable (bool) Set to .Dq YES if you want to run .Pa /etc/uuclean.daily . .It Ar daily_status_network_enable (bool) Set to .Dq YES if you want to run .Ic netstat -i . .It Ar daily_status_network_usedns (bool) Set to .Dq YES if you want to run .Xr netstat 1 without the .Fl n option (to do DNS lookups). .It Ar daily_status_rwho_enable (bool) Set to .Dq YES if you want to run .Xr uptime 1 (or .Xr ruptime 1 if .Ar rwhod_enable is set to .Dq YES in .Pa /etc/rc.conf ). .It Ar daily_status_mailq_enable (bool) Set to .Dq YES if you want to run .Xr mailq 1 . .It Ar daily_status_mailq_shorten (bool) Set to .Dq YES if you want to shorten the .Nm mailq output when .Ar daily_status_mailq_enable is set to .Dq YES . .It Ar daily_status_security_enable (bool) Set to .Dq YES if you want to run .Pa /etc/security . .It Ar daily_status_security_inline (bool) Set to .Dq YES if you want to run .Pa /etc/security inline. The alternative is to run it as a background job, mailing the output to .An root . .It Ar daily_status_security_noamd (bool) Set to .Dq YES if you want to ignore .Xr amd 8 mounts when comparing against yesterdays filesystem mounts. .It Ar daily_status_security_nomfs (bool) Set to .Dq YES if you want to ignore .Xr mfs 8 mounts when comparing against yesterdays filesystem mounts. .It Ar daily_status_mail_rejects_enable (bool) Set to .Dq YES if you want to summarise mail rejections logged to .Pa /var/log/maillog for the previous day. .It Ar daily_status_mail_rejects_logs (num) Set to the number of maillog files that should be checked for yesterday's mail rejects. .It Ar daily_local (str) Set to a list of extra scripts that should be run after all other daily scripts. All scripts must be absolute path names. .El .Pp The following variables are used by the standard scripts that reside in .Pa /etc/periodic/weekly : .Bl -tag -offset 4n -width 2n .It Ar weekly_clean_kvmdb_enable (bool) Set to .Dq YES if you want to purge old .Pa /var/db/kvm_*.db files. The kvm file for the current kernel will not be purged. .It Ar weekly_clean_kvmdb_days (num) Set to the number of days that the file must not have been accessed before being deleted. .It Ar weekly_clean_kvmdb_verbose (bool) Set to .Dq YES if you want the removed files to be reported in your daily output. .It Ar weekly_uucp_enable (bool) Set to .Dq YES if you want to run .Pa /usr/libexec/uucp/clean.weekly . .It Ar weekly_locate_enable (bool) Set to .Dq YES if you want to run .Pa /usr/libexec/locate.updatedb . This script is run using .Ic nice -5 as user .An nobody , and generates the table used by the .Xr locate 1 command. .It Ar weekly_whatis_enable (bool) Set to .Dq YES if you want to run .Pa /usr/libexec/makewhatis.local . This script regenerates the database used by the .Xr apropos 1 command. .It Ar weekly_catman_enable (bool) Set to .Dq YES if you want to run .Pa /usr/libexec/catman.local . This script processes all out of date man pages, speeding up the .Xr man 1 command at the expense of disk space. .It Ar weekly_noid_enable (bool) Set to .Dq YES if you want to locate orphaned files on the system. An orphaned file is one with an invalid owner or group. .It Ar weekly_noid_dirs (str) A list of directories under which orphaned files are searched for. This would usually be set to .Pa / . .It Ar weekly_status_pkg_enable (bool) Set to .Dq YES if you want to use .Xr pkg_version 1 to list installed packages which are out of date. .It Ar weekly_local (str) Set to a list of extra scripts that should be run after all other weekly scripts. All scripts must be absolute path names. .El .Pp The following variables are used by the standard scripts that reside in .Pa /etc/periodic/monthly : .Bl -tag -offset 4n -width 2n .It Ar monthly_accounting_enable (bool) Set to .Dq YES if you want to do login accounting using the .Xr ac 8 command. .It Ar monthly_local (str) Set to a list of extra scripts that should be run after all other monthly scripts. All scripts must be absolute path names. .El .Sh FILES .Bl -tag -width /etc/defaults/periodic.conf .It Pa /etc/defaults/periodic.conf The default configuration file. This file contains all default variables and values. .It Pa /etc/periodic.conf The usual system specific variable override file. .It Pa /etc/periodic.conf.local An additional override file, useful when .Pa /etc/periodic.conf is shared or distributed. .El .Sh SEE ALSO .Xr apropos 1 , .Xr calendar 1 , .Xr df 1 , .Xr gzip 1 , .Xr locate 1 , .Xr man 1 , .Xr msgs 1 , .Xr netstat 1 , .Xr nice 1 , .Xr pkg_version 1 , .Xr rdist 1 , .Xr rc.conf 5 , .Xr ac 8 , .Xr chkgrp 8 , .Xr dump 8 , .Xr mfs 8 . .Xr newsyslog 8 . .Xr periodic 8 . .Sh HISTORY The .Nm file appeared in .Fx 4.1 . .Sh AUTHORS .An Brian Somers Aq brian@Awfulhak.org . diff --git a/usr.sbin/periodic/periodic.8 b/usr.sbin/periodic/periodic.8 index 4ab3dec48855..e15ee2cd1010 100644 --- a/usr.sbin/periodic/periodic.8 +++ b/usr.sbin/periodic/periodic.8 @@ -1,234 +1,233 @@ .\" Copyright (c) 1997 FreeBSD, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd 13 August 1997 .Os FreeBSD 3.0 .Dt PERIODIC 8 .Sh NAME .Nm periodic .Nd run periodic system functions .Sh SYNOPSIS .Nm periodic .Ar directory Ns No ... .Sh DESCRIPTION The .Nm program is intended to be called by cron(8) to execute shell scripts located in the specified directory. .Pp One or more of the following arguments must be specified: .Bl -tag -width Fl .It Cm daily Perform the standard daily periodic executable run. This usually occurs early in the morning (local time). .It Cm weekly Perform the standard weekly periodic executable run. This usually occurs on Sunday mornings. .It Cm monthly Perform the standard monthly periodic executable run. This usually occurs on the first day of the month. .It Ar path An arbitrary directory containing a set of executables to be run. .El .Pp If an argument is an absolute directory name it is used as is, otherwise it is searched for under .Pa /etc/periodic and any other directories specified by the .Va local_periodic setting in .Xr periodic.conf 5 (see below). .Pp The .Nm program will run each executable file in the directory or directories specified. If a file does not have the executable bit set, it is silently ignored. .Pp Each script is required to exit with one of the following values: .Bl -tag -width XXXX .It 0 The script has produced nothing notable in it's output. The .Va _show_success variable controls the masking of this output. .It 1 The script has produced some notable information in it's output. The .Va _show_info variable controls the masking of this output. .It 2 The script has produced some warnings due to invalid configuration settings. The .Va _show_badconfig variable controls the masking of this output. .It >2 The script has produced output that must not be masked. .El .Pp If the relevant variable (where .Ar is the base directory in which the script resides) is set to .Dq NO in .Pa periodic.conf , .Nm will mask the script output. If the variable is not set to either .Dq YES or .Dq NO , it will be given a default value as described in .Xr periodic.conf 5 . .Pp All remaining script output is delivered based on the value of the .Va _output setting. .Pp If this is set to a path name (beginning with a .Dq / Character), output is simply logged to that file. .Xr newsyslog 8 knows about the files .Pa /var/log/daily.log , .Pa /var/log/weekly.log and .Pa /var/log/monthly.log , and if they exist, it will rotate them at the appropriate times. These are therefore good values if you wish to log .Nm output. .Pp If the .Va _output value does not begin with a -.Dq / , -it is assumed to contain a list of email addresses, and the output is -mailed to them. +.Dq / +and is not empty, it is assumed to contain a list of email addresses, and +the output is mailed to them. .Pp If .Va _output -is not set, it defaults to -.Dq root . +is not set or is empty, output is sent to standard output. .Sh ENVIRONMENT The .Nm command sets the .Ev PATH environment to include all standard system directories, but no additional directories, such as .Pa /usr/local/bin . If executables are added which depend upon other path components, each executable must be responsible for configuring its own appropriate environment. .Sh FILES .Bl -tag -width /etc/periodic .It Pa /etc/crontab The .Nm program is typically called via entries in the system default cron table. .It Pa /etc/periodic The top level directory containing .Pa daily , .Pa weekly , and .Pa monthly subdirectories which contain standard system periodic executables. .It Pa /etc/defaults/periodic.conf The .Pa periodic.conf system registry contains variables that control the behaviour of .Nm and the standard .Pa daily , .Pa weekly , and .Pa monthly scripts. .It Pa /etc/periodic.conf This file contains local overrides for the default periodic configuration. .El .Sh EXAMPLES The system crontab should have entries for .Nm similar to the following example: .Pp .Dl # do daily/weekly/monthly maintenance .Dl 0 2 * * * root periodic daily .Dl 0 3 * * 6 root periodic weekly .Dl 0 5 1 * * root periodic monthly .Pp The .Pa /etc/defaults/periodic.conf system registry will typically have a .Va local_periodic variable reading: .Pp .Dl local_periodic="/usr/local/etc/periodic /usr/X11R6/etc/periodic" .Pp To log .Nm output instead of receiving it as email, add the following lines to .Pa /etc/periodic.conf : .Pp .Dl daily_output=/var/log/daily.log .Dl weekly_output=/var/log/weekly.log .Dl monthly_output=/var/log/monthly.log .Pp To only see important information from daily periodic jobs, add the following lines to .Pa /etc/periodic.conf : .Pp .Dl daily_show_success=NO .Dl daily_show_info=NO .Dl daily_show_badconfig=NO .Sh SEE ALSO .Xr sh 1 , .Xr crontab 5 , .Xr periodic.conf 5 , .Xr cron 8 , .Xr newsyslog 8 .Rs .Sh DIAGNOSTICS Exit status is 0 on success and 1 if the command fails for one of the following reasons: .Bl -diag .It usage: periodic No directory path argument was passed to .Nm to specify where the script fragments reside. .It not found Self explanatory. .El .Sh HISTORY The .Nm program first appeared in .Fx 3.0 . .Sh AUTHORS .An Paul Traina Aq pst@FreeBSD.org .An Brian Somers Aq brian@Awfulhak.org diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh index cb849b538ed5..35772efedfd3 100644 --- a/usr.sbin/periodic/periodic.sh +++ b/usr.sbin/periodic/periodic.sh @@ -1,101 +1,102 @@ #!/bin/sh - # # $FreeBSD$ # # Run nightly periodic scripts # # usage: periodic { daily | weekly | monthly } - run standard periodic scripts # periodic /absolute/path/to/directory - run periodic scripts in dir # usage () { echo "usage: $0 " 1>&2 echo "or $0 { daily | weekly | monthly }" 1>&2 exit 1 } if [ $# -lt 1 ] ; then usage fi # If possible, check the global system configuration file, # to see if there are additional dirs to check if [ -r /etc/defaults/periodic.conf ]; then . /etc/defaults/periodic.conf source_periodic_confs fi host=`hostname` export host -tmp_output=/var/run/periodic.$$ +tmp_output=${TMPDIR:-/tmp}/periodic.$$ # Execute each executable file in the directory list. If the x bit is not # set, assume the user didn't really want us to muck with it (it's a # README file or has been disabled). for arg do # Where's our output going ? eval output=\$${arg##*/}_output case "$output" in /*) pipe="cat >>$output";; - *) pipe="mail -s '$host ${arg##*/} run output' ${output:-root}";; + "") pipe=cat + *) pipe="mail -s '$host ${arg##*/} run output' $output";; esac success=YES info=YES badconfig=NO # Defaults when ${run}_* aren't YES/NO for var in success info badconfig do case $(eval echo "\$${arg##*/}_show_$var") in [Yy][Ee][Ss]) eval $var=YES;; [Nn][Oo]) eval $var=NO;; esac done case $arg in /*) if [ -d "$arg" ] then dirlist="$arg" else echo "$0: $arg not found" >&2 continue fi;; *) dirlist= for top in /etc/periodic ${local_periodic} do [ -d $top/$arg ] && dirlist="$dirlist $top/$arg" done;; esac { empty=TRUE processed=0 for dir in $dirlist do for file in $dir/* do if [ -x $file -a ! -d $file ] then output=TRUE processed=$(($processed + 1)) $file $tmp_output 2>&1 rc=$? if [ -s $tmp_output ] then case $rc in 0) [ $success = NO ] && output=FALSE;; 1) [ $info = NO ] && output=FALSE;; 2) [ $badconfig = NO ] && output=FALSE;; esac [ $output = TRUE ] && { cat $tmp_output; empty=FALSE; } fi rm -f $tmp_output fi done done if [ $empty = TRUE ] then [ $processed = 1 ] && plural= || plural=s echo "No output from the $processed file$plural processed" fi } | eval $pipe done