Jon B asked:
I want to schedule a task for the second to the last day of each month. I have read this great article about shell scripting the execution. I have also seen that you can use “L” to represent the last day of the month, but I am using CentOS and cannot use the “L” construct.
I want to run the task at 11PM on the second to last day of each month. I hope to construct a command similar to:
0 23 27-30 * * [ "$(date +%d -d tomorrow" = "L" ] && $HOME/path/to/script
Knowing that I can’t use L to represent the last day of the month, how can I use this logic to schedule my Cron job?
The code samples on that site are erroneous. They have certain shell characters replaced with HTML entities. The quotes also seem to be in the wrong places. I wonder if the author ever looked at that page when writing it…
Once we fix that, and then check to see if the first of the month is in two days rather than one…
0 23 27-30 * * [ $(date +%d -d "2 days") == 01 ] && /where/is/my/script
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.