diff options
author | pst <pst@FreeBSD.org> | 1997-08-12 17:48:49 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1997-08-12 17:48:49 +0000 |
commit | 3c7e85f93caec6a560489e4839cc2751332f39c7 (patch) | |
tree | 0759c0d22cba5ff74068e44606af54e04cbb3a75 /usr.sbin/periodic/periodic.sh | |
parent | 4c37b885439f00dec715439bc54a9cfd3d68dfcd (diff) | |
download | FreeBSD-src-3c7e85f93caec6a560489e4839cc2751332f39c7.zip FreeBSD-src-3c7e85f93caec6a560489e4839cc2751332f39c7.tar.gz |
Initial import of periodic executable control program.
Diffstat (limited to 'usr.sbin/periodic/periodic.sh')
-rw-r--r-- | usr.sbin/periodic/periodic.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh new file mode 100644 index 0000000..fb618db --- /dev/null +++ b/usr.sbin/periodic/periodic.sh @@ -0,0 +1,51 @@ +#!/bin/sh - +# +# $Id$ +# +# Run nightly periodic scripts +# +# usage: periodic { daily | weekly | monthly } - run standard periodic scripts +# periodic /absolute/path/to/directory - run periodic scripts in dir +# + +if [ $# -lt 1 ] ; then + echo "usage: $0 <directory of files to execute>" 1>&2 + exit 1 +fi + +dir=$1 +run=`basename $dir` + +# If a full path was not specified, assume default cron area + +if [ "$dir" = "$run" ] ; then + dir="/etc/cron.d/$dir" +fi + +if [ ! -d $dir ] ; then + ( echo "$0: $dir not found" + echo "" + echo "usage: $0 <directory of files to execute>" + ) 1>&2 + exit 1 +fi + +# Check and see if there is work to be done, if not, exit silently +# this is not an error condition. + +if [ "`basename $dir/*`" = "*" ] ; then + exit 0 +fi + +host=`hostname -s` +echo "Subject: $host $run run output" + +# Execute each executable file in the directory. 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 file in $dir/* ; do + if [ -x $file ] ; then + $file + fi +done |