periodic.sh revision 44008
128112Spst#!/bin/sh - 228112Spst# 344008Sjkh# $Id: periodic.sh,v 1.7 1999/01/01 17:37:33 billf Exp $ 428112Spst# 528112Spst# Run nightly periodic scripts 628112Spst# 728112Spst# usage: periodic { daily | weekly | monthly } - run standard periodic scripts 828112Spst# periodic /absolute/path/to/directory - run periodic scripts in dir 928112Spst# 1028112Spst 1128143Spstusage () { 1228112Spst echo "usage: $0 <directory of files to execute>" 1>&2 1328143Spst echo "or $0 { daily | weekly | monthly }" 1>&2 1428112Spst exit 1 1528143Spst} 1628143Spst 1728143Spstif [ $# -lt 1 ] ; then 1828143Spst usage 1928112Spstfi 2028112Spst 2144008Sjkh# If possible, check the global system configuration file, 2244008Sjkh# to see if there are additional dirs to check 2344008Sjkhif [ -r /etc/defaults/rc.conf ]; then 2444008Sjkh . /etc/defaults/rc.conf 2544008Sjkhelif [ -r /etc/rc.conf ]; then 2628143Spst . /etc/rc.conf 2728143Spstfi 2828143Spst 2928112Spstdir=$1 3028112Spstrun=`basename $dir` 3128112Spst 3228143Spst# If a full path was not specified, check the standard cron areas 3328112Spst 3428112Spstif [ "$dir" = "$run" ] ; then 3528143Spst dirlist="" 3628424Spst for top in /etc/periodic ${local_periodic} ; do 3728143Spst if [ -d $top/$dir ] ; then 3828143Spst dirlist="${dirlist} $top/$dir" 3928143Spst fi 4028143Spst done 4128112Spst 4228143Spst# User wants us to run stuff in a particular directory 4328143Spstelse 4428143Spst for dir in $* ; do 4528143Spst if [ ! -d $dir ] ; then 4628143Spst echo "$0: $dir not found" 1>&2 4728143Spst exit 1 4828143Spst fi 4928143Spst done 5028112Spst 5128143Spst dirlist="$*" 5228112Spstfi 5328112Spst 5442239Sbillfhost=`hostname` 5528112Spstecho "Subject: $host $run run output" 5628112Spst 5728143Spst# Execute each executable file in the directory list. If the x bit is not 5828112Spst# set, assume the user didn't really want us to muck with it (it's a 5928112Spst# README file or has been disabled). 6028112Spst 6128145Spstfor dir in $dirlist ; do 6228145Spst for file in $dir/* ; do 6342152Shoek if [ -x $file -a ! -d $file ] ; then 6428143Spst $file 6528143Spst fi 6628143Spst done 6728145Spstdone 68