dongqiao1888 2017-04-11 14:51
浏览 52
已采纳

我需要在我的服务器上安装composer才能用laravel执行cron作业?

Is my first project in laravel and I am trying to perform a cron job but for some reason this does not seem to work, initially I worked the project in local, then upload it to the server and never installed composer in the cPanel, this is the cause that Does not work ?, I leave the code I have used.

for the command

<?php 
namespace App\Console\Commands;
namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Plan;
use App\Plan_negocio2;
use App\Plan_negocio;
use App\Pagina;
use DateTime;
use Illuminate\Console\Command;

//use Illuminate\Foundation\Inspiring;

class Resaltador extends Command {

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'res:resaltado';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Verificar Resaltador';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $plan=Plan_negocio::all();
        //$fechaAct=$request->fecha;

        if ($plan) 
        {
            $arrNegocio=[];
            foreach ($plan as $key => $value)
             {  
                //$value->fechafin=strtotime("2017-04-07")-time();

            date_default_timezone_set('America/Caracas');   
            $date = new DateTime($value->fechafin);
            $dateHoy=new DateTime();
            //$dat=$dateHoy->getTimestamp();
            $dat=9999999999999999;
            $value->fechafin=$date->getTimestamp();
            //$now = new DateTime();

                //$gene= $date1->format('U') - $now->format('U');


                if ($dat>$value->fechafin) 
                {
                 $negoPlan=Pagina::find($value->negocio_id);
                 $negoPlan->resalta_id=1;
                 $res=$negoPlan->save();

                }

             }
        }

    }

}

code of the kernel.php

  <?php 
   namespace App\Console;

  use Illuminate\Console\Scheduling\Schedule;
  use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

   class Kernel extends ConsoleKernel {
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [

        //'App\Console\Commands\Inspire',
        \App\Console\Commands\Resaltador::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        /*$schedule->command('inspire')
                 ->hourly();*/

                 $schedule->command('res:resaltado')->everyMinute();
    }

}

route of the cron job

The path that I give to the cron job does not give me any errors, so I do not think this is giving errors

the path is this

/usr/bin/php -q home3/pixsony6/public_html/loupper.com/loupper/artisan schedule:run 1>> /dev/null 2>&1

Any suggestions would be good, thanks

  • 写回答

1条回答 默认 最新

  • douhui2307 2017-04-11 19:37
    关注

    No, you do not need Composer to run a cron job with Laravel.
    If you're vendor folder is present with all dependancies then you can run commands.
    Composer is for installing packages to the vendor folder.
    For your specific problem, try using the php-cli instead of php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法