[Sussex] Penguins...
Steve Dobson
steve at dobson.org
Sat Feb 21 21:38:27 UTC 2004
Thomas
On Sat, Feb 21, 2004 at 06:51:12PM +0000, Thomas Adam wrote:
> --- Steve Dobson <steve at dobson.org> wrote:
>
> > Hi Thomas
>
> > Wrong - doesn't met spec. Try again.
>
> B*llocks :) I mean, let's face it, cron will do it, however, my attempt in
> ruby is one-line :)
You're solution was:
* * 0-14,16-31 1-6,8-12 * echo "$(date)" | mail some_user
I agreed that this will send out the e-mails, but it doesn't meet the
spec.
The spec called for "an e-mail message" for each of my unbirtdays. Maybe
I should have been a little clearer, but to me "a message" means *one*
per day. The "* *" in cron will cause cron to execute every minute of
the day. That is 1439 duplicate messages send out on days when the
script is executed.
Also your one line will not send any messages on:
15 Jan, 15 Feb, 15 Mar, ... 15 Dec (That's 11 unbirthdays with no message)
1 July, 2 July, 3 July, ... 31 July (That's 30 unbirthdays with no message)
The 15 July not being my Unbirthday.
(1439 * (356 - 11 - 31)) = 451846 unnecessary messages.
Also the spec called for the subject line of the mail to be set
your solution did not set it.
My first solution was to have two crontab entries:
01 00 1-14,16-31 7 date "+Happy Unbirthday on %A %B %e %Y" | \
/usr/bin/mail -s "Happy Unbirthday" steve at dobson.org
01 00 1-31 1-6,8-12 date "+Happy Unbirthday on %A %B %e %Y" | \
/usr/bin/mail -s "Happy Unbirthday" steve at dobson.org
which is the four commands I needed for my solution:
date * 2 + mail * 2 + cron = 5
But it can be done in one line thus:
01 00 * * * test `date +%m%d` = 0715 && \
date "+Happy Unbirthday on %A %B %e %Y" | \
/usr/bin/mail -s "Happy Unbirthday" steve at dobson.org
But this still requires 5 commands.
date * 3 + mail + cron
It also as the added disadvantage that it requires an extra `fork/execve`
pair to run the "date +%m%d" command. It also runs on my birthday when it is
not needed.
Steve
More information about the Sussex
mailing list