run cron job on end of every month

2019-07-15 10:00发布

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.
enter image description here

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

Any help greatly appreciated, Thanks!.

2条回答
太酷不给撩
2楼-- · 2019-07-15 10:12

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

查看更多
Fickle 薄情
3楼-- · 2019-07-15 10:21

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.

查看更多
登录 后发表回答