Search code examples
cronshopwareshopware6

Is it possible to run a scheduled task each midnight in Shopware?


We have read https://developer.shopware.com/docs/guides/plugins/plugins/plugin-fundamentals/add-scheduled-task which described how to define a scheduled tasks which runs every x minutes.

Is it also possible to specific the execution time, for example each midnight or every day a 2 am, like in a crontab?


Solution

  • I'm not aware of such a feature in Shopware core.
    The probably most straightforward way would be to add a "real" cronjob like you mentioned, which triggers a CLI-command.
    You can encapsulate the logic of the task in it's own service, so that the scheduled task and cli-command both can just use the service (if you want to keep both).