I would like to add a daily job that updates data.
I have the following code:
Event::on(
Controller::class,
Controller::EVENT_BEFORE_ACTION,
static function (ActionEvent $event) {
//Check if is older than 24h
if($check){
//Add a job to queue
}
}
);
The problem with the code is that it only triggers when you are logged in and I would like to find a more efficient way because it is executed with every controller action, it would be enough if it is only executed once a day.
I also don't want to use cronjobs or something similar because the whole thing should happen natively in the plugin.