Skip to content

Instantly share code, notes, and snippets.

@polettix
Created November 21, 2011 11:31
Show Gist options
  • Save polettix/1382375 to your computer and use it in GitHub Desktop.
Save polettix/1382375 to your computer and use it in GitHub Desktop.
simple crontab shell driver
#!/bin/bash
function die () {
echo "$*" >&2
exit 1
}
basedir=$(dirname "$0")
basedir=$(readlink -f "$basedir")
cd "$basedir" || die "cannot hop into $basedir"
unset MODULEBUILDRC
unset PERL_MM_OPT
unset PERL5LIB
export PATH='/home/whatever/silv/perl-5.14.2/bin:/home/whatever/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin'
date=$(date '+%Y-%m-%d')
logfile="log/SILV-$date.log"
/home/whatever/silv/perl-5.14.2/bin/perl -I lib bin/silv -c etc/field.conf >"$logfile" 2>&1
# cleanup older runs
find "log" -type f -name 'SILV-*.log' -not -newermt '-60 days' -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment