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.
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.
This extension does the following:
.ddev/web-build/cron.conf..ddev/web-build/*.cron files to crontab scheduler.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:
/etc/cron.d.See .ddev/web-build/time.cron.example and Examples section below for specific example.
crontab usage, see crontab man page.ddev exec crontab -l.timezone in your .ddev/config.yaml.ddev ssh) and manually run the commands to confirm expected results.IS_DDEV_PROJECT=trueThe following examples are provide as guides. PRs are welcome for changes and updates for current best practices for specific frameworks.
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.
.ddev/web-build/time.cron.example to .ddev/web-build/time.cron./time.log containing the web container’s current time../.ddev/web-build/contao.cron file* * * * * php /var/www/html/vendor/bin/contao-console contao:cron
./.ddev/web-build/drupal.cron fileDDEV_PHP_VERSION value must match your project’s PHP version.*/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
./.ddev/web-build/laravel.cron file* * * * * cd /var/www/html && IS_DDEV_PROJECT=true php artisan schedule:run >> /dev/null 2>&1
./.ddev/web-build/openmage.cron file* * * * * /var/www/html/cron.sh
./.ddev/web-build/typo3.cron file* * * * * cd /var/www/html && IS_DDEV_PROJECT=true vendor/bin/typo3 scheduler:run -vv | tee -a /var/www/html/scheduler-log.txt
./.ddev/web-build/wordpress.cron file*/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
cron.log file in the root of your projectContributed 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)