peppeocchi / php-cron-scheduler

PHP cron job scheduler
MIT License
808 stars 143 forks source link

Run in a time interval #80

Closed elvispdosreis closed 5 years ago

elvispdosreis commented 5 years ago

I need to create a task that runs every day between a time interval, for example Wheels every day every 5 minutes only between 20:00 to 07:00

peppeocchi commented 5 years ago

Hi @elvispdosreis I think the fastest way to get it done is by scheduling the job only between those hours

Example pseudocode

if (date('H') >= 20 && date('H') <= 7) {
    $scheduler->php(....)->at(.....)
}

Of course you can use any date library you want and set any conditions you want to achieve what you need.

There is currently no built in method to do what you are trying to do, but PRs are more than welcome

elvispdosreis commented 5 years ago

thanks