This script is intended to run Drupal activities from system cron by help of Drush.
Originally it has been developed in AWS context, so it may contain some specifics.
- Copy the script to your system
/usr/local/bin/cron-drush.sh
- Give it execution rights
chmod 755 /usr/local/bin/cron-drush.sh
- Configure system cron (see below)
- Configure environment variables (see below)
- Create new cron file (for example
/etc/cron.d/drush
) - Add an entry (see example below)
- Configure environment variables
WEBUSER=apache2
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
0 * * * * root cron-drush.sh cron
Those variables have to be specified in cron file,
or in AWS case those can be also in envvars
which is used automatically.
All environment variables are optional.
-
BASE_URL
In makes sense only in single-site setup when some Drupal functionality may need it and creating drush aliases files is not needed.
Example:https://www.example.com
-
COMPOSER_HOME
This is needed for script to find
drush
. In composer dir there isvendor/bin
which containsdrush
.
Default:/usr/lib/composer/vendor/bin/drush
-
CRON_DRUSH_LOG
Location cron drush logfile.
Default:/var/log/cron-drush.log
-
LEADER_SCRIPT
This is needed only in multi-instance setup where there are multiple web servers against one database. The script determines by exit code 0 which instance is considered "leader" in the group.
The value may be absolute path or relative path. In latter case the script is searched from PATH.
Default:aws-leader.py
, if present in the system. -
WEBROOT
Drush needs to know where Drupal is located.
Default: tries to guess between some common paths. -
WEBUSER
Specifies web server user for running
drush
as.
Default: tries to guess between some common usernames.
- This script is meant to be executed from system cron
- This script is meant to be executed as root
- It passes it's arguments to
drush
, so accepts arbitrarydrush
arguments, not justcron
- See logs at
/var/log/cron-drush.log
- Create leader script if needed.
Modify your cron file. For example:
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
0 * * * * root cron-drush.sh @site1 cron ; cron-drush.sh @site2 cron
Drop drush aliases file into /etc/drush
folder, so that homeless webserver user can find it.
- AWS leader script -- https://github.com/ragnarkurmwunder/aws-leader