0

In my kernel.php schedule() in Laravel 8, I have this line.

$schedule->command('exec "cat /var/log/nginx/access.log | grep -v -e "download" -e "danger" -e "/visitor/return" -e "welcome" -e "GET / HTTP" -e "/baby/" -e "/paste/" | awk "{ print $1, $4, $7 }"')->daily()->emailOutputTo($email)->environments('prod');

If I need to test it and need to run right now, what command do I need to run ?

I've tried this at the root of the project

php artisan schedule:run >> /dev/null 2>&1

Nothing seems to work, I just don't want to wait for a day to see the result.

code-8
  • 54,650
  • 106
  • 352
  • 604

1 Answers1

0

You can do that using the tinker console (php artisan tinker). The following happens inside tinker.

Get the schedule instance from the container

>>> $schedule = app(Illuminate\Console\Scheduling\Schedule::class)

Get the scheduled event (note that I have not added the daily())

>>> $event = $schedule->command('exec "cat /var/log/nginx/access.log | grep -v -e "download" -e "danger" -e "/visitor/return" -e "welcome" -e "GET / HTTP" -e "/baby/" -e "/paste/"
| awk "{ print $1, $4, $7 }"')->emailOutputTo($email)->environments('prod');

Run the event, supplying the container as a parameter - you could chain this run call above as well, obviously.

>>> $event->run(app())
abhiyanp
  • 73
  • 8