Search code examples
phplaravelcronlaravel-scheduler

every 10 minute cron job behavior on two task with 8 hours interval


I am using Laravel schedule task and I have two cron jobs:

One has to run at 00:10

And another one at 08:00

I wanted to know if I set my cron job to this:

*/10 * * * * php .../artisan schedule:run

will this run my jobs? what if this cron job run at these times: 01:05, 01:15, 01:25,... will this run my job at 00:10 if it passes from that time?

And what else could be the best cron job for this situation?


Solution

  • */10 * * * * php .../artisan schedule:run 
    // this will run every 10 minutes: 01:00, 01:10, 01:20
    

    So it's stil workable for your current scenario.

    However, if you have another job at 00:05, then you have to change the cron again, which is not advisable. Why not you just use * * * * * php .../artisan schedule:run ?

    From the documentation.

    This Cron will call the Laravel command scheduler every minute. When the schedule:run command is executed, Laravel will evaluate your scheduled tasks and runs the tasks that are due.