[ale] First three Fridays of a month via a Bash script?

James Sumners james.sumners at gmail.com
Wed Jun 6 10:46:26 EDT 2012


I've been thinking on this one since yesterday and haven't come up
with anything. I have a Bash script that I want to run on the first
three Fridays of every month. I don't think I can setup such a weird
schedule in Cron, so I'm thinking of just running it every Friday and
the script will exit without doing anything if it isn't an appropriate
day.

My preference is to stick with standard utilities and Bash without
resorting to something like Python. The problem I'm encountering is
that GNU date does relative calculations either from the current
system time or from a file's modification time. This means I can't use
a contrived date such as the first of every month to do something like
`date -d 'first Fridate'`, `date -d 'second Friday'`, and `date -d
'third Friday'` because I can't supply two '-d' parameters (one for
the start date and a second for the desired calculation).

So, does anyone have any suggestions on how I can do this?

-- 
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59


More information about the Ale mailing list