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

nat75's avatar

problem using Cron with Laravel 4.2 Command

Hi, first of all excuse me for my english!!

I want use a Laravel Command, that i've created, by calling it in a cron job. In my PC the command works fine by calling it in this way

php artisan command:MyCommand

but when i try to call in the cron job i've created in the production server of a Web Hosting

php /home2/dferdinw/public_html/ff4b/artisan command:MyCommand

i receive this error:

[InvalidArgumentException] Command "command:MyCommand" is not defined. Did you mean this? command:make

So, I've create e new cron job to read le list of command available in this way

php /home2/dferdinw/public_html/ff4b/artisan list

but in the list command:MyCommand doesn' t appear!

Any idea???

0 likes
5 replies
willvincent's avatar

Sounds like your custom command wasn't deployed to production, or the code to register it didn't make it to production. Or a combination of both issues.

nat75's avatar

Hi, I've registered my custom command in app/start/artisan.php

Artisan::add(new MyClass);

in MyClass.php there is the name of command correctly written

protected $name = 'command:MyCommand'

on the PC where i develop is all ok.. in production server i've that error"

anakadote's avatar

Hi @nat75 Did you ever find a solution to this? I have the same problem and no matter what I try my custom commands are "not defined" and do not appear with: php artisan list

jimmck's avatar

Hi,

I had to put the path in my cron file. Once done done, all works fine. MAC OSX, Laravel 4, PHP 5.6.3

Here is my file:

SHELL=/bin/bash PATH=/Applications/:/Applications/XAMPP/xamppfiles/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

          • php /Users/jimm/WebProjects/laravel42/artisan scheduled:run 1>> /dev/null 2>&1

Regards, Jim

I needed to get path in cron task.

Amrit01's avatar

does other command works on production ? if not this may the solution for you :

cd /home2/dferdinw/public_html/ff4b/; php -d register_argc_argv=On artisan command:MyCommand

Please or to participate in this conversation.