CodeIgniter Forums
CodeIgniter 4 Tasks, Execute task in controller ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: CodeIgniter 4 Tasks, Execute task in controller ? (/showthread.php?tid=91758)



CodeIgniter 4 Tasks, Execute task in controller ? - ALTITUDE_DEV - 10-04-2024

Hello,
I would like to know if it is possible to execute a cron task instantly from CI TASK (https://tasks.codeigniter.com/)?

PS: My tasks work perfectly with PHP Spark Task... or via CRON on my live server.

What I want to do:

I have a task in my Tasks.php file:

PHP Code:
$schedule->call(static function () {
    $tasksController = new TasksController();
    $tasksController->TaskCleanLogs();
})->
sundays('0:00')->named('CleanLogs'); 

But if I go into one of my controllers, for example, my Admin panel, in:

PHP Code:
public function index() {
// test
  echo command('tasks:run --task CleanLogs');



This works, but it does not execute the task; it just goes through the file, and here's what I have in var_dump/echo:

Running Task...
Completed Running Tasks

Without actually executing the task in question...
I do not see how to perform this action.

Thank you for your help.
Florian


RE: CodeIgniter 4 Tasks, Execute task in controller ? - InsiteFX - 10-04-2024

PHP Code:
// only thing I can see in the list
->betweenMinutes(0,1



RE: CodeIgniter 4 Tasks, Execute task in controller ? - ALTITUDE_DEV - 10-07-2024

(10-04-2024, 09:57 PM)InsiteFX Wrote:
PHP Code:
// only thing I can see in the list
->betweenMinutes(0,1

Thanks for reply.