#!/bin/sh # events.sh # Copyright (c) 2008 Peter Kuyarov, All rights reserved # #Thu Sep 11 09:51:03 MDT 2008 - 0.5 # finished the weekly/monthly/yearly intergration of events # currently date has to be starting from beginning of line # in the following format: ^2008x12x31-[weekly|monthly|yearly] # where x=any character, and 'weekly' is day of week: # XXXXXXXXXX-Tuesday test weekly-date is ignored # XXXXXXX.13-monthly test monthly-year,month is ignored # XXXX.09.14-yearly test yearly-year is ignored #Wed Sep 10 14:46:06 MDT 2008 - 0.3 # changed $dateformat to $yrdateformat # will have weekly/montly/yearly events #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 in 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="~/birthdays.txt" # how many days forward to look for events # counting starts with 0 daysforward=5 # # end config variables # # date format that this script should look for # currently only supports 2008x12x31 format wkdateformat='+^[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]-%a' mndateformat='+^[0-9][0-9][0-9][0-9].[0-9][0-9].%d-monthly' yrdateformat='+^[0-9][0-9][0-9][0-9].%m.%d-yearly' if [ ! -f $eventsfile ] then echo "$eventsfile does not exist, exiting" exit 1 fi count=0 while [ $count != $daysforward ] do for dateformat in $wkdateformat $mndateformat $yrdateformat; do date=`date -v +${count}d "$dateformat"` grep $date $eventsfile # echo " $date " done count=$(($count+1)) done