Search code examples
laravelcron

Laravel Scheduler not running at 00:00


I have a scheduler command which is querying an API and writing data in a database the code for this command is very long and I am not sure if it's relevant to be posted here, but in essence, what it does it sends get request to another web API does some calculations and then save results in a database.

This command is called data:miner in App\Console\kernel.php i have added this code:

$schedule->command('data:miner')->hourly();

To run command every hour.

The problem is that from the database it looks like that I have no data for midnight 00:00

Here is a dump form database for a certain date

+-------------+---------------------+
| consumption | created_at          |
+-------------+---------------------+
|        0.43 | 2021-04-26 23:02:25 |
|        0.43 | 2021-04-27 01:02:30 |
|        0.43 | 2021-04-27 02:02:34 |
|        0.44 | 2021-04-27 03:02:37 |
|        0.43 | 2021-04-27 04:02:30 |
|        0.43 | 2021-04-27 05:02:32 |
|        0.44 | 2021-04-27 06:01:59 |
|        0.43 | 2021-04-27 07:01:55 |
|        0.43 | 2021-04-27 08:02:00 |
|        0.44 | 2021-04-27 09:02:14 |
|        0.44 | 2021-04-27 10:02:02 |
|        0.44 | 2021-04-27 11:02:05 |
|        0.44 | 2021-04-27 12:02:31 |
|        0.44 | 2021-04-27 13:02:31 |
|        0.44 | 2021-04-27 14:02:31 |
|        0.44 | 2021-04-27 15:02:33 |
|        0.44 | 2021-04-27 16:02:29 |
|        0.44 | 2021-04-27 17:02:26 |
|        0.44 | 2021-04-27 18:02:35 |
|        0.44 | 2021-04-27 19:02:29 |
|        0.44 | 2021-04-27 20:01:09 |
|        0.44 | 2021-04-27 21:01:08 |
|        0.44 | 2021-04-27 22:02:17 |
|        0.43 | 2021-04-27 23:02:17 |
|        0.44 | 2021-04-28 01:02:16 |
+-------------+---------------------+
25 rows in set (0.49 sec)

Solution

  • The problem was that I had more commands before this command in the kernel.php

    One of the commands before data:miner was taking long to execute and was blocking other commands