Book Image

Drush for Developers - Second Edition

By : Juan Pablo Novillo Requena, Juan P Novillo Requena
Book Image

Drush for Developers - Second Edition

By: Juan Pablo Novillo Requena, Juan P Novillo Requena

Overview of this book

Table of Contents (13 chapters)
Drush for Developers Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Keeping Database Configuration and Code Together
Index

Running a task outside cron


So far in this chapter, we have seen how to disable Drupal's automatic cron and how to schedule it to be run by Drush. Now, we have got to the point where we can evaluate whether there are any tasks running at cron in our Drupal project that should be moved out of it.

Here are the reasons why a task that runs within hook_cron() (https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_cron/7) might need to be moved to its own process:

  • The task might take a variable time to complete; sometimes, it will run in a couple of seconds, whereas for others, it might take an hour

  • You want to run the task manually if you need to, and enter different input parameters depending on the circumstances

  • The task's runtime log is highly valuable; therefore, it has to be saved into a different logfile with its own purging strategy

Whatever the reason, you can run any code within a custom Drush command and then schedule its processing through any of the methods...