I am following this tutorial 매분 기능을 예약하십시오. 아래는 localhost에 관한 나의 코드이다.작업 예약 : Laravel 5.3
class Kernel extends ConsoleKernel
{
protected $commands = [
'App\Console\Commands\Inspire',
];
protected function schedule(Schedule $schedule)
{
$schedule->call($this->WriteFile())->everyMinute();
}
protected function commands()
{
require base_path('routes/console.php');
}
private function WriteFile() {
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
fclose($myfile);
}
}
txt 파일에 내용이 표시되지 않는 것으로 나타났습니다. 나는 공용 폴더에 txt 파일을 넣었다. 내가 놓친 게 있니? 내가이가 내 Kernal.php
에서
Artisan::command('writeFile', function() {
Storage::disk('local')->put('file.txt', 'this is text !');
});
: 파일 console.php
내 Console Routes
에서
당신은 당신의 서버에 크론 항목을 추가 했습니까? – istaro
이것은 로컬 호스트에 관한 것입니다. – Pankaj