Laravel 4 无法为Laravel4设置Cron

Laravel 4 无法为Laravel4设置Cron,laravel-4,cron,Laravel 4,Cron,在过去的3天里,我一直在绞尽脑汁为我的网站设置cron。在我的cpanel中,我提到了一个cron,它将每5分钟运行一次,命令是 wget http://www.example.com/artisan cron:run 在我的工匠中,我添加了 Artisan::add(new CronRunCommand); 并且CronRunCommand.php是 <?php use Illuminate\Console\Command; use Symfony\Component\Console

在过去的3天里,我一直在绞尽脑汁为我的网站设置cron。在我的cpanel中,我提到了一个cron,它将每5分钟运行一次,命令是

wget http://www.example.com/artisan cron:run
在我的工匠中,我添加了

Artisan::add(new CronRunCommand);
并且CronRunCommand.php是

<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class CronRunCommand extends Command {
    protected $name = 'cron:run';
    protected $description = 'Run the scheduler';
    protected $timestamp;
    protected $messages = array();
    protected $runAt = '03:00';
    public function __construct()
    {
        parent::__construct();
        $this->timestamp = time();
    }
    public function fire()
    {
        $this->everyFiveMinutes(function()
        {
            // In the function, you can use anything that you can use everywhere else in Laravel.
            $affectedRows = User::where('logged_in', true)->update(array('logged_in' => false)); // Not really useful, but possible
            Artisan::call('auth:clear-reminders');
            $this->messages[] = $affectedRows . ' users logged out';
        });
        $this->dailyAt('09:00', function()
        {
            Mail::send('hello', array(), function($message)
            {
                $message->to('admin@mydomain.com', 'Cron Job')->subject('I am still running!');
            });
        });
        $this->finish();
    }
    protected function finish()
    {
        // Write execution time and messages to the log
        $executionTime = round(((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000), 3);
        Log::info('Cron: execution time: ' . $executionTime . ' | ' . implode(', ', $this->messages));
    }
    protected function yearly(callable $callback)
    {
        if(date('m', $this->timestamp) === '01' && date('d', $this->timestamp) === '01' && date('H:i', $this->timestamp) === $this->runAt) call_user_func($callback);
    }
}

这非常有效,我已经开始定期发送电子邮件
wget