[ale] First three Fridays of a month via a Bash script?
leam hall
leamhall at gmail.com
Wed Jun 6 10:54:45 EDT 2012
Would `date +%a` == 'Fri' && (`date +%d` <= 21) or something similar work?
I've not tested it, but that's the track I would take.
Leam
On 6/6/12, James Sumners <james.sumners at gmail.com> wrote:
> 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
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
--
Mind on a Mission <http://leamhall.blogspot.com/>
More information about the Ale
mailing list