Run Elysia cron from Drush
Elysia Cron is an extension to Drupal’s standard cron system. With standard Drupal cron, all cron jobs are run at the same time. Elysia Cron gives much more control and allows you to set different intervals for each cron. Elysia cron does not actually run cron, instead it schedules what should be run when the standard cron is run. It does this by skipping certain cron tasks if they are setup to run less frequently than the current crontab settings. You just need to setup the normal Drupal cron to run at regular enough intervals.
But sometimes you need to manually fire a particular cron job. For example, let’s say you have a cron task that runs a Feed to pull data into your Drupal site from another source. It is scheduled to run every 4 hours but your client wants it run now for testing purposes.
You have two options. You can run the task from the user interface, or from Drush.
Running from Drush
To run a cron job from Drush, all you need to know is the cron jobs name. Head over to Configuration > System > Cron Settings in the administration section of your site and you will see a list of all of the cron jobs that are managed by Elysia cron. In the left hand column, under Job/Rule you will find the cron jobs name.
Here is an example:
To run the
feeds_cron job in Drush, use the elysia-cron run command along with the name:
- drush elysia-cron run feeds_cron
Let’s look at another example. Let’s say you want to run the backup and migrate cron job.
To run the
backup_migrate_standard job in Drush, use the elysia-cron run command along with the name:
- drush elysia-cron run backup_migrate_standard
If you want to run cron jobs on a regular basis, you can always save these commands in a code snippet or text expansion tool like Text Expander to make your life easier.
Running from UI
You can also run the cron job directly in the UI by click on the run link.
If you liked this, you'll love my book, Master Drupal Module Development.
"..the must have drupal developers book"
Feeling stuck with Drupal 8 module dev?
Get the free 7 lesson course that will help you get started today without feeling overwhelmed.
- Create Drupal modules with just a few commands using the Drupal Console
- Create custom pages
- Create custom blocks
- Create admin forms
- Demystify routers and controllers
- Bonus material