Skip to content

Dynamic cron based on model value

I made a simple custom CRUD module.

My table have 4 columns: id, name, action, schedule.

Action is a select where I can select a controller.

Schedule is a text field where I can store for example: * * * * *.

This means that every row I add in the table can have a different sheduled time.

id | name | action              | schedule
1  | abc  | PathToCronScript1 | 0 0 * * *
2  | bca  | PathToCronScript2 | 0 2 * * *

I would like PathToCronScript1 to be executed every day at midnight

and PathToCronScript2 to be executed every day at 2am.

Cannot find any reference online.
Any suggestion will be appreciated