laravel 4的cron工作赢了

时间:2016-05-06 10:40:49

标签: php laravel-4 cron

我在laravel 4中关注这个Cron Job with Laravel 4作为cron的教程,但它似乎无法正常工作。这是我的/app/commands/ReleaseOptionBooking.php

<?php

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

class ReleaseOptionBooking extends Command {

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Check booking expirations';

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

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        $to = "bikegearup@gmail.com";
        $subject = "My subject";
        $txt = "Hello world!";
        $headers = "From: admin@theskitrip.ca" . "\r\n";

        mail($to,$subject,$txt,$headers);
    }

    /**
     * Get the console command arguments.
     *
     * @return array
     */
    protected function getArguments()
    {
        return array(
            array('example', InputArgument::REQUIRED, 'An example argument.'),
        );
    }

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

}

这是/app/start/artisan.php

Artisan::add(new ReleaseOptionBooking);

并在我的服务器上crontab -e

*/10 * * * * php /var/www/myproject/protected/artisan release:option

有人对我的案子有所了解吗?

我收到了这个错误:

  [RuntimeException]
  Not enough arguments.



release:option [--example[="..."]] example

2 个答案:

答案 0 :(得分:1)

您是否拥有对服务器的ssh访问权限? 你可以尝试手动执行命令:

php /var/www/myproject/protected/artisan release:option

您是否看到任何错误消息?任何输出?

答案 1 :(得分:0)

从命令代码中删除这些示例:

/**
 * Get the console command arguments.
 *
 * @return array
 */
protected function getArguments()
{
    return array(
        array('example', InputArgument::REQUIRED, 'An example argument.'),
    );
}

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