To run a cronjob script on the last day of a month, you can use the L
character in the day of the month field of the crontab entry.
The L
character specifies the last day of the month, and can be used to schedule a cronjob to run on the last day of the month.
Here is an example of how you can use the L
character to schedule a cronjob to run on the last day of the month:
# Run the script at 11:00 PM on the last day of the month 0 23 L * * /path/to/script.shSource:www.lautturi.com
This will run the script /path/to/script.sh
at 11:00 PM on the last day of the month.
Note that the L
character can only be used in the day of the month field, and not in the day of the week field. If you want to run the cronjob on the last day of the week, you can use the 7L
or L
characters in the day of the week field.
For example, to run the cronjob on the last Sunday of the month, you can use the following crontab entry:
# Run the script at 11:00 PM on the last Sunday of the month 0 23 * * 7L /path/to/script.sh
This will run the script /path/to/script.sh
at 11:00 PM on the last Sunday of the month.
Overall, the L
character is a useful tool for scheduling a cronjob to run on the last day of the month. It allows you to easily schedule a cronjob to run on the last day of the month, without having to manually calculate the specific date.