the environmental background of the problems and what methods you have tried
in laravel framework, linux environment, xshell executes crontab scheduled tasks,
they said that the root directory of the executed project is the absolute path, which I have tested as the absolute path, but I don"t know why it hasn"t been executed.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
php
namespace AppConsole;
use AppHttpControllersLogController;
use Log;
use IlluminateConsoleSchedulingSchedule;
use IlluminateFoundationConsoleKernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\MsgTask::class
];
/**
* Define the application"s command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command("msg:send")->everyMinute();
/* $schedule->call(function () {
new LogController( 4 , "" );
})->everyMinute();*/
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__."/Commands");
require base_path("routes/console.php");
}
}
php
namespace AppConsoleCommands;
use IlluminateSupportFacadesApp;
use IlluminateConsoleCommand;
use Log;
use AppHttpControllersLogController;
class MsgTask extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = "msg:send";
/**
* The console command description.
*
* @var string
*/
protected $description = "Msg send";
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Log::info("test");
//new LogController( 4 , "" );
}
}
commands in crontab:
-
- / usr/bin/php / www/wwwroot/default/test/artisan schedule:run > > / dev/null 2 > & 1