I’m horrible with dates. I forget anniversary’s and birthday’s like it’s nobody’s business. So, in order to stop irritating family members, I decided to find some software that would remind me about important events.
Most reminder software pops up a little reminder window, X number of [minutes|hours|days] before the scheduled event takes place. I live in a web browser most of the time, and the scourge of pop-up windows of yore have firmly engrained within me the autonomic reflex of instantly closing unbidden windows. So, that feature wouldn’t work for me.
I could just keep everything written down on a calendar and refer to the events as they pop-up, but that hasn’t worked for me in the past either. Similarly, keeping a list of these dates just don’t get reviewed. I suppose that putting them in a tickler file, GTD fashion, would work, but that, too, hasn’t worked for me in the past. I wish there was something simple that could send me email at the first of the month reminding me of all of the birthdays and anniversarys coming up that month. I live in email. Email gets read.
Well, since I couldn’t find anything that did what I wanted, I just hacked together a little script.
Basically, what we’re doing here is writing a script to parse a list of names, dates and a one-letter attribute to determine whether the date is an anniversary or birthday, and then get cron to run on the first of the month and email you a pretty list of dates that are coming up this month and whether they’re birthday’s or anniversary’s.
This script is not intended to replace existing reminder software but is supplemental. Your current reminder software probably does a really good job of reminding you about the board meeting, little Timmy’s soccer game this Saturday, and the oil change for your Winnebago you missed about two weeks ago. Where most of the reminder software lacks, in my humble opinion, is reminding you that Aunt Tillie’s birthday is this month, and if you don’t remeber her birthday, it’s going to cause her to have another series of strokes.
In case you haven’t picked up on it yet, download monthly_reminders.sh, chmod it 700 and place it in your $PATH (echo $PATH to find where you can put executables). Once you’ve got the script downloaded, open it up and scroll down to the bottom, do you see the line where it says mail -s "$subject" phil < $TMP, you need to change “phil” to your username unless, your username is also phil, then, well, you’re pretty much done with this step.
Next, we have to make the data file with all of the dates and names and whatnot. This isn’t that hard, it’s a plain text file with a little bit of formatting. Basically, the format goes, 0127<TAB>B<TAB>John Paul. The first bit is the day-month that the event takes place, in this case 01 (January) 27 (twenty-seventh), this is followed by a tab. Secondly, there’s the one-letter-code identifier, A for anniversary or B for birthday, then another tab. Finally, there’s the name of the person(s) associated with the event, in this example, my brother. Create a file, based on this format, and save it to $HOME/.family.
It’s very important that you manually type the tab key between the bits of information, and only have one reminder per line.
Once you have this in place, type monthly_reminders.sh from a terminal and then check your mail. There should be a new mail with the subject line “Family Events for May”. When you read the mail it’ll look something like this:
Wayne's Birthday is May 02. Stella's Birthday is May 10. Ed's Birthday is May 11. Ben's Birthday is May 12. Kim's Birthday is May 23.Now, let’s automate it, becuase, honestly, if you could remeber to run the script at the first of every month, you probably don’t need it anyway. Type
crontab -e from a teminal to open your crontab in the default editor and append the following line:
0 0 1 * * /path/to/monthly_reminders.sh
Cron can be a little stupid at times, make sure you have the full path to wherever you installed the script and end the crontab with a blank line. Once the modification is made, save and exit out of the editor and cron should tell you that you did a good job (crontab: installing new crontab).
Making it work for you
This little script makes a few assumptions, mainly that you have the programmail installed. It’s the default on most Linux systems, with one exception I can think of immediately, Slackware. Slackware uses the nail program which is, arguably, better. I haven’t tested this script with nail, but if you’re running Slackware, replace the mail with nail and let me know how it works out.
Secondly, this script assumes your MUA pulls in mail off the system spool. If yours doesn’t, this script won’t do much for you, and configuring your MUA to do so is beyond the scope of this article. Debian does this by default, so does Slackware, if you’re running an RPM-based system God have mercy on your soul.
Posted by Philip McClure in Linux on May 21, 2005