Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

133
Vistas
Laravel 5.4 task scheduler

I have setup scheduler according to the Laravel 5.4 documentation. But it doesn't work.

My cron job is:

* * * * * php public_html/demo/artisan schedule:run 1>> logs/cronlog.txt

app/console/Kernel.php:

class Kernel extends ConsoleKernel
{    
    protected $commands = [Commands\OverdueTasksNotifier::class,];

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('notify:overduetasks')->everyFiveMinutes();
    }

    protected function commands()
    {
        require base_path('routes/console.php');
    }
}

app/Console/Commands/OverdueTasksNotifier.php:

class OverdueTasksNotifier extends Command
{
    protected $signature = 'notify:overduetasks';

    protected $description = 'Sends alerts (email, sms) for un-Ready overdue tasks.';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        echo 'test';
    }
}

and the cronlog.txt has:

    [ErrorException]                         
    Invalid argument supplied for foreach()

Content-type: text/html; charset=UTF-8

and above text repeats every minute.

I ran php artisan list and it lists the added command above which is notify:overduetasks.

Could someone point me where the error is? I use shared hosting (cPanel).

----- UPDATE -----

debug enabled and the laravel.log is:

[2017-04-29 21:02:02] local.ERROR: exception 'ErrorException' with message 'Invalid argument supplied for foreach()' in /home/serverhostcom/public_html/demo/vendor/symfony/console/Input/ArgvInput.php:284
Stack trace:
#0 /home/serverhostcom/public_html/demo/vendor/symfony/console/Input/ArgvInput.php(284): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Invalid argumen...', '/home/serverhos...', 284, Array)
#1 /home/serverhostcom/public_html/demo/vendor/symfony/console/Application.php(764): Symfony\Component\Console\Input\ArgvInput->hasParameterOption(Array, true)
#2 /home/serverhostcom/public_html/demo/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->configureIO(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/serverhostcom/public_html/demo/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(123): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/serverhostcom/public_html/demo/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 {main}  
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I found it was to be a typo in paths to php and artisan.

/usr/local/bin/php /home/[USERNAME]/public_html/artisan schedule:run >> /dev/null 2>&1

Now task scheduler runs properly.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda