Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel Cronjobs #37

Open
iammart opened this issue Oct 20, 2021 · 1 comment
Open

Laravel Cronjobs #37

iammart opened this issue Oct 20, 2021 · 1 comment

Comments

@iammart
Copy link

iammart commented Oct 20, 2021

Would you consider an update to the documentation for managing cronjobs for Laravel installs?

This is based on my existing setup and the advice from the Laravel documentation.

Laravel's command scheduler allows you to fluently define your command schedule within your Laravel application itself and not within the cron entry itself.

I setup a single cronjob on the server that hits the scheduler every minute.

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

In its most very basic form I will implement the schedule method on App\Console\Kernel, and schedule the commands to execute and and how often to repeat.

For eg.

The following command has a list of jobs that needs to be executed "every minute".

* * * * * php /path/to/artisan aimeos:jobs "order/export/csv order/email/delivery order/email/payment order/email/voucher order/service/delivery subscription/export/csv customer/email/account"

We can replace this with the schedule command which can be committed and managed through the repository.

protected function schedule(Schedule $schedule) 
{
    $schedule->command($this->buildCommand('aimeos:jobs', [
        'order/export/csv',
        'order/email/delivery',
        ...
        'customer/email/account'
    ]))->everyMinute();
}

Similarly, those jobs that need to run every hour...

protected function schedule(Schedule $schedule) 
{
    $schedule->command($this->buildCommand('aimeos:jobs', [
        'customer/email/watch',
        ...
        'order/service/payment',
    ]))->hourly();
} 

There may be a reason why you haven't taken this approach that im unaware off, only I did notice that the TYPO3 is managed differently to Symphony and Laravel setups so its not necessarily for consistency across the supported platforms.

If you are happy with the suggestion I can fork the repo and create a pull request with my amendments?

@aimeos
Copy link
Owner

aimeos commented Oct 21, 2021

Yes, if you can create a PR how to configure scheduler task in Laravel, we will happy to merge it into the docs :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants