1

I have been reading about the Drush cron and explanation that mentions in this documentation. Wondering do we add that crontab entry for drush locally or on the server where the website is for the production site? This confusion is because the article mentions drush aliases.

This is the crontab entry suggested

10 * * * * /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COLUMNS=72 /usr/local/drush/drush --root=/path/to/your/drupalroot --uri=your.drupalsite.org --quiet cron

Here is the part that is confusing

Specifying the Drupal site to run

There are many ways to tell Drush which Drupal site to select for the active command, and any may be used here. The example uses the --root and --uri flags, but you could also use an alias record if you defined it in a global location, such as /etc/Drush/aliases.Drushrc.php.

Does it refer to aliases on my local or possible aliases on the server which may have dev, qa and other related sites.

1 Answer 1

1

TL;DR You should add it on the server!

Whereas it's possible to add it locally and use a remote alias to run it on the server it would be unreliable (requires your local to be online 24/7) and inefficient.

That said, you can also add "local" aliases on your server for convenience, to avoid adding the --root and --uri flags to the command in your crontab.

You can add any number of Drush aliases anywhere you want; so on your local machine you can have a "foo.local", "foo.staging" & "foo.prod" aliases for your site. And on your staging and production servers, you can simply add "foo.staging" and "foo.prod" so that you can access all of your environments in a cohesive and consistent manner.

The advantage is that if you define an alias "foo.prod" on the production server, you can replace your crontab command with this: /usr/local/drush/drush @foo.prod --quiet cron

It's customary to have the same aliases set up across all servers for that very purpose.

5
  • Thanks for adding the explanation, I updated the question to include the part that was confusing me.
    – pal4life
    Jun 1, 2015 at 13:10
  • Updated answer again :) In the example you listed, it looks like referring to aliases on the server.
    – Alex Weber
    Jun 1, 2015 at 13:15
  • Do you have a take on Drush cron? either recommending it or advising against it or neutral? Thanks.
    – pal4life
    Jun 1, 2015 at 13:17
  • It's better because it saves you 1 request as it triggers cron directly, the alternative would be to hit your site's cron.php and include the security token, which is perfectly fine too, just more verbose again. drupal.stackexchange.com/questions/18326/…
    – Alex Weber
    Jun 1, 2015 at 13:19
  • I'm signing off now, check the stack overflow chat if you need more real-time support! thanks! :)
    – Alex Weber
    Jun 1, 2015 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.