Reputation: 929
Let's say I have a long-lived process to run "Backup Database 1"
I want that to run in every night. (and see result in log)
Also, I want to run it manually sometimes via Artisan Command. (see result in command line)
Also, I need an html button to run it in my HTML Interface. (see result in screen)
What's the best approach?
Notes:
Laravel documentation says you can execute commands in the queue, adding more confusion.
I tried the example, but the --queue option is not automatically implemented
https://laravel.com/docs/5.6/artisan#programmatically-executing-commands
Artisan::queue('email:send', [
'user' => 1, '--queue' => 'default'
]);
Upvotes: 1
Views: 1166
Reputation: 859
Create the artisan command and make the job call it in your app/Console/Kernel like this:
$schedule->command("command_name")->dailyAt("00:00")->thenPing(env("PING_BACKUP_DB"));
Use the ping part if you're using forge to check that your command is running.
Then create the route you need and run the command you need, see here from Laravel Docs
Try Artisan:call
instead of queue, you'll see the example if you scroll down a little bit on the link attached
Upvotes: 4