I want to schedule my script for last Saturday of every month. I have come up with the below:
45 23 22-28 * * test $(date +\%u) -eq 6 && echo "4th Saturday" && sh /folder/script.sh
Is this correct or I need to change it? I can't test it right now as it will be invoked only on last saturday. Please advise.
I have the below for last sunday of every month but i can't understand much of it. The first part gives 24 which is sunday and after -eq gives 7 which i don't know what it means:
00 17 * * 0 [ $(cal -s | tail -2 | awk '{print $1}') -eq $(date | awk '{print $3}') ] && /folder/script.sh
Can I modify the above to get last saturday?
With Romeo's help I was help to come up with the below answer:
00 17 * * 6 [ $(cal -s | tail -2 | awk '{print $7}') -eq $(date | awk '{print $3}') ] && /folder/script.sh