在CPanel Laravel中设置CronJob

时间:2015-10-06 07:01:36

标签: php laravel cron cpanel

我在cpanel中设置了一个cronjob,我正在使用laravel 4.2。我还设置将cronjob发送到我的电子邮件,黄色部分下面是我在电子邮件中收到的错误。

  

[InvalidArgumentException]

     

“user”命名空间中没有定义命令。

// laravel command.php

<?php

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class CronDelFilesCommand extends Command {

/**
 * The console command name.
 *
 * @var string
 */
protected $name = 'user:active';

/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Command description.';

/**
 * Create a new command instance.
 *
 * @return void
 */
public function __construct()
{
    parent::__construct();
}

/**
 * Execute the console command.
 *
 * @return mixed
 */
public function fire()
{
    echo "aaa";
}

/**
 * Get the console command arguments.
 *
 * @return array
 */
protected function getArguments()
{
    return array(

    );
}

/**
 * Get the console command options.
 *
 * @return array
 */
protected function getOptions()
{
    return array(
        array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
    );
}

}

// cpanel中的命令

* * * * * /usr/bin/php /home/project/public_html/artisan user:active > /home/project/public_html/log.txt

怎么了?什么是错误意味着什么?

已更新

感谢@KristianHareland,我使用了wget。 :)

1 个答案:

答案 0 :(得分:0)

我想你忘了把这个命令添加到工匠app/start/artisan.php

你喊道:

Artisan::add(new CronDelFilesCommand());

不要忘记composer dump-autoload 您可以找到更多信息here