[英]Laravel cron job is not working in bluehost
這是我的Kernel.php代碼
protected $commands = [
'App\Console\Commands\cronEmail'
];
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->everyMinute();
}
這是我的cronEmail.php代碼
protected $signature = 'inspire';
public function handle()
{
$name="asdfasdfasfd";
$email="asdfasdfasfd";
$phone="asdfasdfasfd";
$pass="asdfasdfasfd";
$type="asdfasdfasfd";
$discount=32542345;
$data=array("customer_name"=>$name,"customer_email"=>$email,"customer_phone"=>$phone,"customer_password"=>$pass,"customer_type"=>$type,"customer_discount"=>$discount);
DB::table('customer_det')->insert($data);
}
當我在cmd中運行此命令時,以上代碼工作正常
php artisan schedule:run
我嘗試在bluehost上運行此命令,但仍然無法正常工作.. !!
/usr/bin/php /home2/pakhakee/public_html/esabzi/artisan schedule:run 1>> /dev/null 2>&1
我在bluehost服務器上嘗試了上述命令,但仍然無法正常工作!
請更改您的kernel.php
並檢查如下:
protected $commands = [
\App\Console\Commands\cronEmail::class
];
更新的答案
cronEmail.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use DB;
use Config;
use Mail;
class cronEmail extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inspire';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name="asdfasdfasfd";
$email="asdfasdfasfd";
$phone="asdfasdfasfd";
$pass="asdfasdfasfd";
$type="asdfasdfasfd";
$discount=32542345;
$data=array("customer_name"=>$name,"customer_email"=>$email,"customer_phone"=>$phone,"customer_password"=>$pass,"customer_type"=>$type,"customer_discount"=>$discount);
DB::table('customer_det')->insert($data);
}
}
並在終端中運行php artisan inspire
命令
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.