
Drupal 7 - Elysia Cron & the Feeds Module
Published: 12/22/2015
NOTE: My Drupal environment is locally hosted, and I have root access to the web and database servers, which are Red Hat Linux. This may make my processes different from someone with a different setup.
I intially struggled to understand how the Drupal Feeds module interacted with Cron. Despite a number of articles available online, it took me a while to get it right. The one most important step - and probably the least intuitive to me - is setting up the Drupal Cron job to run EVERY MINUTE at your server level. This worried me, because I assumed that all of Drupal's various cron requests, from feeds to caching to system maintenance, would try to run every minute. However, this is where the Elysia Cron module takes over.
Finally, set up your feed and importer at /admin/structure/feeds. This article will not fully cover the details of creating and configuring a feed, but gives mention to the following items:
- Run crontab -e from a command line on the server that contains the Drupal installation. My job looks like this, where domain is my domain name and cron key is the value from admin/config/system/cron/settings.* * * * * /usr/bin/wget -o - -q -t http://domain/cron.php?cron_key=xxxxx (opens in new tab)
- Install Elysia Cron (opens in new tab) and configure. This is where you gain granular access over each of the Drupal threads that would typically run within the Cron job scheduled in #1. Now, out of the box, you get one setting for all Feeds. You can write a custom module to expand on this, but the base functionality allows only one frequency for all Feeds. If, like me, you only have two feeds, this isn't a problem. I set feeds_cron to run every 15 minutes. It works great. I can't say that the same would be true for a site running many large feed imports.
- In additional to scheduling feeds_cron to run at a particular interval in Elysia Cron, I also had to tell job_scheduler_cron to run at the same interval - for me, every 15 minutes:
- The Basic Settings - Periodic Import I set to As often as possible. This setting by itself does nothing. It's Cron and Elysia Cron that run your import.
- I also check Import on submission and Process in background.
- On the Settings for File upload, I check Supply path to file or directory directly and public: Public local files served by the webserver.
- On the Import page, I place the file to be imported in the public:// directory. For my Drupal installation, this is sites/default/files/
And that's how I schedule all of my feeds to run automatically every 15 minutes.
