As discussed in previous blog post, drush cron can be run from crontab too. While seeming pretty straightforward, trying it out caused some troubles.
The thing you would do to make drush run from crontab is:
$ crontab -e * * * * * drush -r /path/to/drupal
Also tried to give full path to drush install
$ crontab -e * * * * * /usr/local/bin/drush -r /path/to/drupal
This didnt work for me. To see the output of your command:
$ tail -f /var/mail/root
Why? It seems the environment variables arent the same when running the command in terminal as in from crontab.
Try this:
$ crontab -e * * * * * env > /tmp/cronenv.log
$ env > /tmp/bashenv.log
$ diff /tmp/bashenv.log /tmp/cronenv.log
In my case copying PATH to the head of crontab did the trick:
$ crontab -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 0 * * * * /usr/bin/drush -r /path/to/drupal cron
Links
[1] https://dominiquedecooman.com/blog-topics/cron
[2] https://dominiquedecooman.com/blog-topics/drush
[3] https://dominiquedecooman.com/blog-topics/cli