last day (15 days later) » 

10:13
0
Q: Laravel Forge Scheduler - Run Command

JamesWhen using Laravel Forge's scheduler, you can trigger all the cronjob by e.g. running: php /home/forge/default/artisan schedule:run However, when wanting to execute a sole command, it will fail and says "fatal: not a git repository (or any of the parent directories): .git". Via SSH, I would ...

/default/ should be the folder name - I suspect not yours is not 'default' either. Here is a piece of tutorial
@senty so rather php /home/forge/default command:name? Or should it be php /home/forge/default artisan command:name (without the /)?
php /home/forge/your_folder_name/artisan command:name
@senty I don't want to run the scheduler but a specific command - that's why I posted this question. Running the scheduler for the cronjob work.
Yes, it's same approach. Fixed my previous comment
10:13
@senty but this leads to this message: "fatal: not a git repository (or any of the parent directories): .git" - which is weird as the "schedule:run" gives no error message but the command does.
Wait - don't you need to utilize scheduler even to run only 1 job with a logic (for example, once a day ie ->daily())?
Yes, but here I want to run a command with Laravel Forge's scheduler that is NOT part of the Cronjob.
So you want to include it in your deploy script?
When do you want to run it?
Laravel FORGE (forge.laravel.com) has an option to schedule commands. And I want to schedule a command that executes a "php artisan" command. Hope it's clearer
And how will you trigger it?
10:17
With Laravel Forge's "scheduler" feature.
but you said you don't want to run it on an interval :/
I'd put it in a scheduler, run schedule:run (every minute) as cron and handle the frequency of a single command with the Frequency Options laravel.com/docs/5.8/scheduling#schedule-frequency-options
It won't work with our current multi-server setup. It will only run on the cronjob server where we explicitly do not want it to run.
->onOneServer();
We have multiple application servers, so it won't fix that problem.
Do I understand it correctly then, that there is no way to run a command in scheduler that executes one specific artisan command?
Let's say you have a Command called send:emails
$schedule->command('send:emails')->daily()->onOneServer();
But if you don't run the schedule:run, it won't check every minute if it's time for the send:emails command to run
Sorry I can't be of much help
10:24
And how would I run this via Forge Scheduler?
php /path send:emails ?
or php /path artisan send:emails ?
or php /path/artisan send:emails ?
yes
Which option? 😅
path/artisan
wait
Thanks, but its weird as this results in the error
"fatal: not a git repository (or any of the parent directories): .git"
path artisan
10:25
without slash?
yes
with space
what happens?
Well, nothing specifically
I guess it works then
use the logger to see if it runs
Log::info("x")
Yep, will check but I guess that's the solution
Thanks a lot!
Hope it helped, happy coding pal :)
10:27
Cheers mate, have a nice day

last day (15 days later) »