#!/bin/sh # events.sh # Copyright (c) 2008 Peter Kuyarov, All rights reserved # #Thu Sep 4 14:48:04 MDT 2008 - 0.1 #events.sh # this will scan through file looking for upcoming/current dates/events # events are put one per line starting with date in $dateformat format # by default in '+%m.%d' format # will scan/notify $daysforward to notify of upcoming events # '2008.08.16 eventX' # '2003/01/16 Janu 16th 2008 event Y' # '1990-10-23 1990 October 23rd - event Z' # year are ignored, only looking at month and day values # # this was written to not have to put up tons of cronjobs for reminders, # now getting all birthdays, special dates in one file/location # and just have this one script in cron to run nightly # # scripts@pknet.net # http://peterk.org/scripts/ # PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin export PATH # # start config variables # # events file eventsfile='~/events.txt' # how many days forward to look for events daysforward=5 # date format that this script should look for dateformat='+%m.%d' # # end config variables # if [ ! -f $eventsfile ] then echo "$eventsfile does not exist, exiting" exit 1 fi while [ $daysforward != 0 ] do date=`date -v +${daysforward}d "$dateformat"` grep $date $eventsfile daysforward=$(($daysforward-1)) done