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
で
は、あなたのサーバーへのCRONのエントリを追加したことがありますか? – istaro
これはローカルホストに関するものです。 – Pankaj