Artificial intelligent assistant

Bash condition that won't run on first Thursday of the month I have a cron that runs a script twice a week (Monday/Thursday) - this runs fine, but I need to stop it processing on the first Thursday of the month. I'd like to adapt this code: we=$(LC_TIME=C date +%A) dm=$(date +%d) if [ "$we" = "Thursday" ] && [ "$dm" -lt 8 ] then ..... fi I would assume I just change the = to != but wonder if there would be any gotchas I need to be aware of? This question (where I got the code above from) is the opposite of what I want \- I would actually have preferred to add a comment to the accepted answer to ask this question, but I'd need 50 rep.

Using a bash test:


if [[ "$(LC_TIME=C date +%A)" == 'Thursday' && "$(date +%d)" -le 7 ]]; then
exit 1
fi


Note: Functionally this is no different than the test in your question.

Just add that to the top of your script. If it is the first thursday of the month the script will exit right away, otherwise it will run.

Alternatively you could put it right into your crontab entry, something like:


0 1 * * 1,4 [[ "$(LC_TIME=C date +\%A)" == 'Thursday' && "$(date +\%d)" -le 7 ]] || /path/to/script.sh

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ac47ea4ab053b7fb543e5a69073332a1