2015-09-16 211 views
0

我已經註冊了我的命令,php artisan run:process,它看起來像運行cron作業5

class queuedTransaction extends Command 
{ 
    /** 
    * The name and signature of the console command. 
    * 
    * @var string 
    */ 
    protected $signature = 'run:process'; 

    /** 
    * The console command description. 
    * 
    * @var string 
    */ 
    protected $description = 'Running the queued transaction.'; 

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

    /** 
    * Execute the console command. 
    * 
    * @return mixed 
    */ 
    public function handle(){ 
     DB::table('transfers')->truncate(); 
    } 

} 

這是我kernel.php

class Kernel extends ConsoleKernel 
{ 

    protected $commands = [ 
     \App\Console\Commands\Inspire::class, 
     \App\Console\Commands\queuedTransaction::class, 

    ]; 


    protected function schedule(Schedule $schedule) 
    { 


     $schedule->command('run:process')->everyMinute(); 

    } 
} 

現在我想運行php artisan run:process每分鐘和截斷transfers表,但cron現在不工作。只是爲了確保,如果command本身工作與否,我把我的command放在我的routes的內部並調用它,它截斷表意義命令正在完成它的工作。

回答

0

在Kernel.php您的命令應包括在:

/**                            
* The Artisan commands provided by your application. 
* 
* @var array 
*/ 
protected $commands = [ 
    MyCommand::class 
]; 

你或許可以去除啓發太:)

+0

我已經擁有它..我剛添加的代碼的一部分..但其那麼.. – Sid

+0

那麼用戶在運行cronjob?無法寫入日誌可能會阻止執行。因此,如果Apache在www-data下運行,但您的登錄用戶正在運行cronjob,那可能會導致它。檢查/ var/log/syslog(如果適用)以查看cronjob是否正常運行,或者如果在它之後立即顯示錯誤。 – markdwhite

+0

我添加了我的命令,如'/ usr/local/bin/php/home/smsnep5/public_html/projectname/artisan schedule:run schedule:run >>/dev/null 2>&1',但它沒有做任何好處。但支持團隊說cron作業正在運行 – Sid