I have a series of entries for my crontab to run a script on specific dates that correspond with our bi-weekly payroll schedule. I am completely clear on the fact that cron does not support year as an interval, but I found guidance elsewhere that leads to the versions here (the "..." is where I abbreviated the folder structure):
30 10 20 4 * [[ $(date "+\%Y") == 2020 ]] && /usr/bin/php /var/www/.../payroll-w.php >/dev/null 2>&1
30 10 4 5 * [[ $(date "+\%Y") == 2020 ]] && /usr/bin/php /var/www/.../payroll-w.php >/dev/null 2>&1
30 10 18 5 * [[ $(date "+\%Y") == 2020 ]] && /usr/bin/php /var/www/.../payroll-w.php >/dev/null 2>&1
In theory, these example lines should run at 10:30 AM on 20 April 2020, 4 May 2020, and 18 May 2020-- but then be skipped entirely in 2021 and beyond.
I was thinking about using an array in the PHP file that is called by cron to "check" the date and only run when it matches, but that is a non-ideal solution. Any advice on how to correct my apparent error above?
NOTE: I use this method on two servers-- one runs Debian Jessie and the other runs CentOS 8.
Thank you in advance!