Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 4 Tasks, Execute task in controller ?
#1

(This post was last modified: 10-04-2024, 06:19 AM by ALTITUDE_DEV.)

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
Reply
#2

PHP Code:
// only thing I can see in the list
->betweenMinutes(0,1
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

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

Thanks for reply.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB