1#!/bin/sh - 2# 3# $Id: periodic.sh,v 1.7 1999/01/01 17:37:33 billf Exp $ 4# 5# Run nightly periodic scripts 6# 7# usage: periodic { daily | weekly | monthly } - run standard periodic scripts 8# periodic /absolute/path/to/directory - run periodic scripts in dir 9# 10 11usage () { 12 echo "usage: $0 <directory of files to execute>" 1>&2 13 echo "or $0 { daily | weekly | monthly }" 1>&2 14 exit 1 15} 16 17if [ $# -lt 1 ] ; then 18 usage 19fi 20 21# If possible, check the global system configuration file, 22# to see if there are additional dirs to check 23if [ -r /etc/defaults/rc.conf ]; then 24 . /etc/defaults/rc.conf 25elif [ -r /etc/rc.conf ]; then 26 . /etc/rc.conf 27fi 28 29dir=$1 30run=`basename $dir` 31 32# If a full path was not specified, check the standard cron areas 33 34if [ "$dir" = "$run" ] ; then 35 dirlist="" 36 for top in /etc/periodic ${local_periodic} ; do 37 if [ -d $top/$dir ] ; then 38 dirlist="${dirlist} $top/$dir" 39 fi 40 done 41 42# User wants us to run stuff in a particular directory 43else 44 for dir in $* ; do 45 if [ ! -d $dir ] ; then 46 echo "$0: $dir not found" 1>&2 47 exit 1 48 fi 49 done 50 51 dirlist="$*" 52fi 53 54host=`hostname` 55echo "Subject: $host $run run output" 56 57# Execute each executable file in the directory list. If the x bit is not 58# set, assume the user didn't really want us to muck with it (it's a 59# README file or has been disabled). 60 61for dir in $dirlist ; do 62 for file in $dir/* ; do 63 if [ -x $file -a ! -d $file ] ; then 64 $file 65 fi 66 done 67done 68