Raised: $0
0% of monthly goal Help us cross the finish line!
Goal: $12,000
Raised: $0 Goal: $12,000
0% of monthly goal Help us cross the finish line!
Sponsor DDEV

add-on registry tests last commit release

DDEV Cron

Overview

The cron command-line utility is a job scheduler on Unix-like operating systems.

This add-on:

This extension is designed to be a generic implementation. See Running TYPO3 Cron inside the web container for a specific example of a manual setup.

Installation

To install this add-on, run:

ddev add-on get ddev/ddev-cron
# modify/rename/adjust the time.cron file for your needs
cp .ddev/web-build/time.cron.example .ddev/web-build/time.cron
ddev restart

After installation, make sure to commit the .ddev directory to version control.

Usage

This extension does the following:

*.cron

This addon uses *.cron files to populate crontab. This allows projects to track and manage cron jobs via git.

On ddev start, all .ddev/web-build/*.cron files are:

See .ddev/web-build/time.cron.example and Examples section below for specific example.

Useful sites and debugging

Examples

The following examples are provide as guides. PRs are welcome for changes and updates for current best practices for specific frameworks.

Logging current time

This addon provides an example that can check if the cron service is running. Every minute, it writes the current time (UTC timezone) to ./time.log.

Contao cron

* * * * * php /var/www/html/vendor/bin/contao-console contao:cron

Drupal cron

*/10 * * * * IS_DDEV_PROJECT=true DDEV_PHP_VERSION=8.1 /var/www/html/vendor/bin/drush cron | tee -a /var/www/html/cron-log.txt

Laravel cron

* * * * * cd /var/www/html && IS_DDEV_PROJECT=true php artisan schedule:run >> /dev/null 2>&1

OpenMage cron

* * * * * /var/www/html/cron.sh

TYPO3 scheduler

* * * * * cd /var/www/html && IS_DDEV_PROJECT=true vendor/bin/typo3 scheduler:run -vv | tee -a /var/www/html/scheduler-log.txt

WordPress cron

*/15 * * * * IS_DDEV_PROJECT=true DDEV_PHP_VERSION=8.1 cd /var/www/html && /usr/local/bin/wp cron event run --due-now 2>&1 | tee -a /var/www/html/cron.log

Credits

Contributed and maintained by @tyler36 based on the original Running TYPO3 Cron inside the web container by @thomaskieslich

Originally contributed by @thomaskieslich in https://github.com/ddev/ddev-contrib/tree/master/recipes/cronjob)