I'm running a scheduled task every 5 minutes, to do it I added this to schedule
inside App\Console\Kernel
$schedule->call(function(){ $this->bajarProveedores(); })->everyFiveMinutes() ->appendOutputTo(storage_path('\logs\schedule.log'));
I've tried with backslash and forward slash for the file path and I used file_exists(storage_path('\logs\schedule.log'))
to check if the file was there. The method runs without errors and it returns a string but nothing is appended to schedule.log
, the method looks something like this:
private function bajarProveedores() { try { // DO SOME STUFF HERE } catch (FileNotFoundException $exception) { die('File: '.$filename.' error'); } return 'File: '.$filename.' OK'; }
I checked that file exists and I'm working on Windows with L5.1. Is this the right way to do it?
Any suggestions?
appendoutputTo() and sendOutputTo() are exclusively for the command method and are not supported for the call method. If you would like to use these functions you will have to utilize the Command method. https://laravel.com/docs/5.1/scheduling#task-output
P.S. I am on laravel 5.8 and I still get this problem I don't think it was ever supported for call, if so I haven't figured it out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With