Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

enthusiast14's avatar

Commands not firing inside the schedule method of laravel scheduler

I am trying to run artisan commands by laravel scheduler, i followed exactly the documentation of scheduling. here is the cron job set in my hostinger shared hosting control panel to start the laravel scheduler -

***** /usr/bin/php /home/u483465152/public_html/artisan schedule:run

in my app/console/kernel.php file, i put following two commands in schedule method -

$schedule->command('user_transaction:sync') ->everyMinute() ;

$schedule->call(function () { Log::info("call test done"); })->everyFiveMinutes();

For the first command above, following codes are in the User_Transaction.php command file located in app/console/commands folder -

class User_Transaction extends Command { protected $signature = 'user_transaction:sync';

protected $description = 'Command description';

public function __construct()
{
    parent::__construct();
}
public function handle()
{
    Log::info("cron job user transaction command handle ");
}

}

But i see that cron job works and it enters the schedule method (i tested by log) but the two commands in the schedule method is not firing !!, plz help, i have been struggling for more than 12 hours, i really tried many options all the ways, where is the leak?

Thanks in advance.

0 likes
13 replies
khalilm's avatar

What happens if you just run the second method with the logging? Does it work?

guybrush_threepwood's avatar

You can attempt to log the output of the scheduler to a file to see if its running:

***** /usr/bin/php /home/u483465152/public_html/artisan schedule:run &>> /home/u483465152/artisan.log

Also check storage/logs/laravel.log for errors.

enthusiast14's avatar

@khalilm did you mean this method - $schedule->call(function () { Log::info("call test done"); })->everyFiveMinutes(); ? no logging doesn't work.

@guybrush_threepwood in hostinger i tried to add your cron command but the character ">>" is not being taken.

khalilm's avatar

Yes, I meant to run ONLY that command and see if it works. If I remember correctly, I had this issue and when the first job failed the others did not run.

Also, does your provider give you the option to email the output of the cron command like @guybrush_threepwood suggested? For me it is an option that I specifically have to override by sending outputting it to a null file otherwise cPanel will send an email to the email I have specified in the interface

1 like
Snapey's avatar

Oh no. Not someone else putting their entire project in public_html

What's the matter with these people?

enthusiast14's avatar

@khalilm yes i did put call method first but no logging i received. It's look like i am not finding options to email the output via command text or by settings in hostinger. But could you tell me why these 2 commands not running although cron job works and it does enter in schedule method in kernel file?!!

khalilm's avatar

Yes it doesn't make any sense as on the surface it all seems correct. Any chance you can post your entire kernel.php file?

enthusiast14's avatar

@khalilm Kernel.php -

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use App\Console\Commands\Admin_transaction; use Log;

class Kernel extends ConsoleKernel { protected $commands = [

];

protected function schedule(Schedule $schedule)
{
    //this log works
    Log::info("cron job - kernel schedule method entered: ");

    //following log doesn't work
    $schedule->call(function () {
        Log::info("cron job - kernel schedule method call: ");
    })->everyMinute();
            
}

/**
 * Register the commands for the application.
 *
 * @return void
 */
protected function commands()
{
    $this->load(__DIR__.'/Commands');
    //require base_path('routes/console.php');
}

}

khalilm's avatar

Oh man, I see absolutely nothing wrong with your code. I have tried it on my machine and it works. The only things I can suggest is to try it locally using:

php artisan schedule:run or php artisan schedule:work

and see if it works. Otherwise you may be have to chalk it up to one of those things and start with a fresh install of Laravel and copy over your code again.

enthusiast14's avatar

it does run locally well by the command php artisan schedule:run

enthusiast14's avatar

For record, at last i found out that somehow i had app->Exceptions folder missing, that's why it wasn't working.

Snapey's avatar

For record, app\Exceptions folder only exists if you create your own exception

enthusiast14's avatar

but it seems Exceptions folder within app folder is there by default in laravel 5.8

Please or to participate in this conversation.