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

Anonymous194's avatar

php artisan schedule:run is not triggering the commands properly

Hi,

So I have Kernel.php like this:

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        'App\Console\Commands\IcalConvert',
        'App\Console\Commands\NewsScrape',
        'App\Console\Commands\CinemaScrape',
        'App\Console\Commands\DownloadIcal',
        'App\Console\Commands\EventCreate',
        'App\Console\Commands\EventDelete',
        'App\Console\Commands\EventUpdate',
        'App\Console\Commands\DeleteOldEvents',
        'App\Console\Commands\ClearEvents',
        'App\Console\Commands\EventReCalculate',
        'App\Console\Commands\MondayEmail',
        'App\Console\Commands\UploadToS3'
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $ping =  config('app.ping');
        /*
        $schedule->command('scrape:news')
                 ->hourly()
                 ->weekdays()
                 ->between('7:00', '18:00')
                 ->sendOutputTo($log)
                 ->thenPing($ping);
        */
        $schedule->command('scrape:cinema')
                 ->dailyAt('04:00')
                 ->sendOutputTo($log)
                 ->thenPing($ping);
        $schedule->command('ical:download')
                 ->hourly()
                 ->sendOutputTo($log)
                 ->thenPing($ping);
        $schedule->command('ical:convert')
                 ->hourly()
                 ->sendOutputTo($log)
                 ->thenPing($ping);
        $schedule->command('events:forcedelete')
                 ->dailyAt('02:00')
                 ->sendOutputTo($log)
                 ->thenPing($ping);
        $schedule->command('events:recalculate')
                ->dailyAt('2:15')
                ->sendOutputTo($log)
                ->thenPing($ping);
        $schedule->command('event:clear')
                 ->everyTenMinutes()
                 ->sendOutputTo($log)
                 ->thenPing($ping);
    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        require base_path('routes/console.php');
    }
}

and in forge:

205984 Every Minute * * * * * forge php /home/forge/app.com/current/artisan schedule:run

What happens is that the log says command is being triggered i.e:

scheduling scrape:cinema etc,

However nothing happens. Command should be calling a job which should go to the queue, but the queue is empty!

When I manually trigger the command it works fine!

When I schedule a job in forge like this:

205986 Every Minute * * * * * forge php /home/forge/app.com/current/artisan scrape:cinema

It also works fine.

What is going on...

0 likes
10 replies
AdrianHernandezLopez's avatar

It looks that $log is not defined and is used in all the commands as follows:

->sendOutputTo($log)

I'd say that you need to define it. I'd suggest to split the logs our you will end up with the same log used for multiple commands (for example at 4:00 or 2:00 according to your setup).

Hope this helps

Anonymous194's avatar

It is defined and why would it work if I manually trigger the command or schedule exact command from laravel forge?

AdrianHernandezLopez's avatar

205986 Every Minute * * * * * forge php /home/forge/app.com/current/artisan scrape:cinema will trigger the command directly, without ->dailyAt('04:00') ->sendOutputTo($log) ->thenPing($ping);

Please try to remove ->sendOutputTo($log) or to define the log in the schedule function.

Anonymous194's avatar

@AdrianHernandezLopez I did define it:

$log = /home/forge/app.com/current/log.log

When I removed ->sendOutputTo($log) it starts to work but why when it is defined just above the $ping

AdrianHernandezLopez's avatar

It could be related to a privilege access constraint. Try to replace $log value to $log = storage_path() . 'log.log'; and see if that helps.

Anonymous194's avatar

Nope, still doesn't work :( hold on I could see it in the queue, however it did not create the file, when I manually created it, it is always empty

AdrianHernandezLopez's avatar

Could you add

touch($filePath);

where $filePath is the path of the file, before

$ping = config('app.ping');

so the file is created as soon as schedule:run is fired.

Please or to participate in this conversation.