【发布时间】:2016-12-12 18:19:42
【问题描述】:
我创建了一个示例计划作业,以在 Laravel 5.2 中的特定时间后运行。这在 localhost 到 artisan 命令上运行良好。
我在本地服务器上运行这个命令:
php artisan Demo:Cron
现在我在 HostGator 托管服务器上的 cPanel 的高级选项 cron 作业中添加此任务。但它不起作用。
这是我正在尝试的命令:
cd /home/pofindia/public_html/beta-var1/ && /usr/local/bin/php artisan Demo:Cron
PHP 版本:默认为 5.4。 这是我的示例文件
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use DB;
class DemoCron extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'demo:cron';
/**
* 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 handle()
{
DB::table('items')->insert(['name'=>'hello new']);
$this->info('Demo:Cron Cummand Run successfully!');
}
}
【问题讨论】:
-
可能运行
/usr/local/bin/php /home/pofindia/public_html/beta-var1/artisan Demo:Cron -
感谢您的回复,但它对我不起作用。 cpanel 的设置是否有问题...或从托管服务提供商处激活某些内容。如果是的话如何检查..
-
那么最好问问hostgator的家伙
-
尝试删除
DB的电话,只留下$this->info()。
标签: php cron laravel-5.2