Configuring cronjobs in the Dropsolid Experience Cloud
All projects on Dropsolid Experience Cloud support the use of scheduled (cron) jobs.
- Out of the box all drush commands are supported.
- Custom cronjobs are also supported but do require infra to set them up.
There are however some caveats as a developer, you have to be aware of:
- The >, | and ; characters have special meaning in bash, we thus restrict the use of these characters. Look in the best practices section below for some examples of common use cases.
- Creating cronjobs of any type for a live environment can currently only be done by infra
Therefore, crons looking like the examples below are not valid (anymore):
drush @PROJECT.ENV ev 'shell_exec("cp ../file.default ../file");'
drush @PROJECT.ENV migrate-import products; drush @PROJECT.ENV migrate-import --group=product_translations
drush @PROJECT.ENV cron > /var/www/project_type/PROJECT/ENV/private/files/logs/log.txt
Best practices¶
- Use a script to
- Execute multiple commands that should be executed sequentially
- Store the output of a cron in a non-default logfile (see logs section below)
-
Use drush core-execute to run shell scripts you have written to execute bash commands.
drush @PROJECT.ENV core-execute ../etc/cron/script.sh
-
Use a PHP script and drush scr instead of running a single command using drush ev.
drush @PROJECT.ENV scr --script-path=../etc/cron/script.php
- Store scripts meant to be used as crons in PROJECT/etc/cron
- Test your Drush commands on the web server before adding them to the Experience Cloud as cron jobs to ensure everything works.
Logs¶
You can download the cron logs using the "Download logs" action of an environment. If the logs are not available in the list for your specific cronjob, contact infra and specify which cronjobs you would like logs for.