I want to run a script on (say) the 4th friday every month. But if I include this line in the crontab :
45 9 22-28 * 5 echo '4th Friday'|mailx -s "Fri week 4" mike
it sends me mail if the date is 22-28, OR the day is friday. So I get mail every day for a week , and also every friday.
I want it to send mail if the date is 22-28 AND the day is friday.
Any ideas?
Many thanks, Mike
one way is to change the script, also in cron consider always using full qualifiers for
external commands: e.g., /usr.bin/mailx
45 9 22-28 * * [ "$(date +%A)" = "Friday" ] && echo '4th Friday'|/usr/bin/mailx -s "Fri week 4" mike
You also need to know what shell is the cron default (usually /bin/sh) - example: /bin/sh on Solaris is very different from ksh or bash
1 Like
Thanks Jim, I had thought about calling script every day for a week, and the script checking the day, but that's a better way to do it.
Regards, Mike