vendredi 13 août 2021

Php artisan schedule:run only once execute command in localhost

I created a command artisan to make a text file in my path. This command executes correctly by running the command but not for task scheduling in my localhost (not server).

CreateFile class:

protected $signature = 'create:file';

public function handle()
{
    $myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
    $txt = "parisa";
    fwrite($myfile, $txt);
    fclose($myfile);
}

Kernel.php:

protected $commands = [
    Commands\CreateFile::class,
];

protected function schedule(Schedule $schedule)
{
    $schedule->command('create:file')->everyMinute();
}

When I run php artisan schedule:run my command executes only once at that moment. But I want to execute every minute. How to fix it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire