0

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?

Community
  • 1
  • 1
Roham Shojaei
  • 440
  • 4
  • 18
  • You should use " * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1 " as mentioned in [documentation](https://laravel.com/docs/5.8/scheduling#introduction) . That will not miss any job either it is in 8 hrs interval or at 00:10. – nitin7805 Jun 12 '19 at 09:22
  • @nitin7805 Thanks I know that this is offered by documentation to do this every minute but I don't want to do that I have a shared hosting on this website. – Roham Shojaei Jun 12 '19 at 09:38
  • Questions that ask _"Give me a cron-schedule expression that runs a job at X"_ with no attempt are off-topic on Stack Overflow. Cron-schedule expressions are very well explained on the plethora manuals available such as [`man 5 crontab`](//linux.die.net/man/5/crontab), [The Cron wiki-page](//en.wikipedia.org/wiki/Cron), [The SO cron-info page](//stackoverflow.com/tags/cron/info) and most importantly [Why is my crontab not working, and how can I troubleshoot it?](//serverfault.com/questions/449651). Tools that can help you out are http://crontab.guru and http://www.cronmaker.com – kvantour Jun 12 '19 at 12:17

2 Answers2

1
*/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.

Cloud Soh Jun Fu
  • 1,456
  • 9
  • 12
0

You need to only run one cron for laravel schedule task. What you need to change is set time for that schedule task. Please refer https://laravel.com/docs/5.8/scheduling. This has much better explanation on schedule task in laravel.

Dhananjay Kyada
  • 1,015
  • 1
  • 6
  • 14
  • Thank you, I know that but I don't want to have a cron job for every minute because lack of resources I have a shared hosting for this website – Roham Shojaei Jun 12 '19 at 09:42