Do I have to run cron every minute for Laravel's task scheduler, or is it OK to run less frequently?

873 views Asked by At

I've read the relevant part of the docs and various guides, but I'm unclear as to whether Laravel requires the the cron to be run every minute, or whether it's OK to run less often, i.e. hourly, daily, weekly, etc, without causing issues?

In my case I need a script to run monthly; at the end of each month. It has to run at UTC-12 hours (i.e. the time at which the given calendar month will cease to exist everywhere on earth). Do I really need to run the cron job every minute for this, or does it suffice to run every hour? I would assume running it every hour will be fine without causing issues, but I'd like to confirm this.

1

There are 1 answers

1
Yuriy Vorobyov On

Cron can be started at any time. You can "play" with Cron at this site. If I understand the question correctly, the solution you need: 0 0 1 * *

This is a run at the beginning of each month. This is necessary because the Cron does not know when there are 31 days in a month and when there are 30 or less.

Or you could do something like this: 59 23 28-31 * *, but then the Cron will be triggered every month from the 28th to the 31st.