daycry / cronjob

- Manage Cron jobs in Codeigniter 4
MIT License
64 stars 20 forks source link

Tasks are not triggered simultaneously in the same minute. #34

Closed mullernato closed 1 month ago

mullernato commented 7 months ago

I have the following tasks:

+------------------+---------+--------------+----------+---------------------+ | Name | Type | Expression | Last Run | Next Run | +------------------+---------+--------------+----------+---------------------+ | set_data_to_main | command | /5 | -- | 2024-03-22 10:30:00 | | collect_status | command | /10 | -- | 2024-03-22 10:30:00 |

or like in this other case

+------------------+---------+--------------+---------------------+---------------------+ | Name | Type | Expression | Last Run | Next Run | +------------------+---------+--------------+---------------------+---------------------+ | set_data_to_main | command | /4 | 2024-03-22 10:56:01 | 2024-03-22 11:00:00 | | collect_status | command | /11 | 2024-03-22 10:45:01 | 2024-03-22 11:00:00 |

The issue occurring is that the task that runs every 5 minutes is not triggered when the minutes end with 0 (or in coinciding minutes) as in the example above.

In the example case, only the collect_status task runs, and the set_data_to_main task does not run.

The set_data_to_main task is only running at minutes ending with 5 (05, 15, 25, 35, ...).

The collect_status task takes between 4 to 9 minutes to complete.

If the collect_status task is running and the set_data_to_main task is called, it runs normally as long as the two do not coincidentally start in the same minute.

daycry commented 6 months ago

Hi,

You can use threads for this Jobs. For example supervisor for Linux.

But I Will think another type for manage this type of Jobs, for example reading Jobs for run and save in array for manage later.

daycry commented 3 months ago

Fixed in v2.2.27

All jobs save in array for process later and avoid losing jobs