-->

run cron job on end of every month

2019-07-15 10:13发布

问题:

I need to run a script at 2 pm on the end of every month. The reason i set 2 pm is i've a timezone of asia/calcutta and it differs 10 hrs and 30 min. from the server time.

I've set date_default_timezone_set('Asia/Calcutta') in my script, so for the current settings i can trigger 1st day of every month as per my timezone.

But the issue is, i'm using webmin and there is no settings to run end of every month and only date from 1 - 31 listed. Here i attached the screenshot.

How can i run the script on end of the every month at 2pm?

Any help greatly appreciated, Thanks!.

回答1:

The simple way, but ugly

is set to run on every 28,29,30,31 days. Each time when script is launched compare current day with max days in current month using bash/oerl script



回答2:

Have it run every day starting the 28th of every month through the first of the next month. In the script, check if tomorrow is the first day of a month. If so, run, else die.