I'm doing a Task Scheduling, when I run that in local and executed the command 'schedule: run', everything works perfectly, however, when I try to activate the task from the server nothing happens, investigated on the way in which routes are handled in cpanel, I have introduced several paths to the cron job, but still does not work, which do you think error? Could I be on the route I'm giving to cron?
my code is this command:
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Plan;
use App\Plan_negocio2;
use App\Plan_negocio;
use App\Pagina;
use DateTime;
class Resaltador extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'Resaltador:demo';
/**
* The console command description.
*
* @var string
*/
protected $description = 'command';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* 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();
$response["success"][]=true;
}else
{
$response["success"][]=false;}
}
$result=json_encode($response);
}
\Log::info($result.'Hey dude I am here'.\Carbon\Carbon::now());
}
}
kernel:
<?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 = [
Commands\Inspire::class,
Commands\Resaltador::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('Resaltador:demo')->everyMinute();
}
}
route:
/usr/bin/php -q home3/pixsony6/public_html/loupper.com/loupper/artisan schedule:run 1>> /dev/null 2>&1
As I said before, when executing the command schedule: run, the changes are made, I do not understand that it could be failing, initially I worked the project in local and then I uploaded it to the cpanel, the folder structure is the following
-public_html
-loupper.com
--loupper
The loupper folder contains laravel and, as I have read, I must provide the path to artisan.
via Felipe Castillo