简体   繁体   English

Laravel Cron作业在bluehost中不起作用

[英]Laravel cron job is not working in bluehost

Here is my code of Kernel.php 这是我的Kernel.php代码

protected $commands = [
    'App\Console\Commands\cronEmail'
];

protected function schedule(Schedule $schedule)
{
     $schedule->command('inspire')->everyMinute();
}

Here is my cronEmail.php code 这是我的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);
}

Above of my code is working fine when i run this command in cmd 当我在cmd中运行此命令时,以上代码工作正常

php artisan schedule:run

I tried running this command on bluehost but it's still not working ..!! 我尝试在bluehost上运行此命令,但仍然无法正常工作.. !!

/usr/bin/php /home2/pakhakee/public_html/esabzi/artisan schedule:run 1>> /dev/null 2>&1

I tried above command on bluehost server but it's still not working!! 我在bluehost服务器上尝试了上述命令,但仍然无法正常工作!

Please change your kernel.php and check like: 请更改您的kernel.php并检查如下:

protected $commands = [
    \App\Console\Commands\cronEmail::class

];

Updated Answer 更新的答案

cronEmail.php 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);
        }
}

AND run php artisan inspire command in Terminal 终端中运行php artisan inspire命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM