I have a 2 rules that should run each on a specific time interval instead of the regular cron job setting.
I have a list of "Sessions" (entity type) that should be evaluated to see if their booking has expired, if their starting date is in the past, etc. and then certain settings should be updated on each.
I have another list of "Events" (entity type) that does something similar but shouldn't be executed with the same frequency as the Sessions.

Both are rules components.

My first problem

These components fire when I force run my cron job with Elysia Cron module and that works. But it should be automatic. So I have assigned the "rules_cron" job to a new channel, "channel 2" and it should run every hour but it doesn't do that. rules_cron apparently runs every 48 hours or so.

rules_cron apparently runs every 48 hours or so

My second problem

What I really need is the Session component to run every hour and the Event component to run every 15 minutes?

What am I doing incorrectly and how do I accomplish that?

Elysia Cron installation settings

rules_cron is set to channel 2


3 Answers 3


What I really need is the Session component to run every hour and the Event component to run every 15 minutes?

According to your screenshot, it seems you're only running Cron once a day, so even having a shorter schedule than that will not work unless your Cron runs at those needed intervals.

Re-configure your crontab to run at the shortest interval needed. In your case this will be 15 minutes. The configuration of each of those schedules should still ensure that whichever cron hook is only run at the specified times.

  • 1
    Got it. So if I understand correctly, I change the (default) cron job setting to 15 minutes or lower and then I update all the other cron jobs so that they run at their appropriate times instead of every 15 minutes as the default cron job, is that correct?
    – BassPlaya
    Commented Dec 11, 2020 at 0:36

For cron jobs more frequent than every 60 minutes, you'll need to add a crontab to the system. I usually set my crontabs to run as frequently as possible, which is once every 60 seconds. This will give you the most granular control over job timing.

Bear in mind that Elysia/Ultimate cron only check as often as you specify. So, they might check every 15 minutes, but if cron, itself, is also running once every 15 minutes, then your timing could be off by up to 14:49. Consider that Elysia Cron might check for a job just before the crontab job fires, resulting in Elysia thinking that it is not yet time. It has to wait another 15 minutes until the next check.

Setting the crontab to run once every 60 seconds ensures that your job is not delinquent by more than 59 seconds.

To set up your crontab, please follow these steps:

  • Get the link to your site's cron job from /admin/config/system/cron
  • Open a console on your local machine or remote server, as appropriate, and execute: crontab -u www-data -e. Replace www-data with the appropriate user if that is not your web server's user.
  • In the crontab, add an entry like this: * * * * * /usr/local/bin/wget --no-check-certificate --quiet -O - <my cron link>, replacing <my cron link> with the link that you copied. Also, BE SURE there is a trailing new line. You also might need to modify the path to wget. use which wget to determine the path.

Once you set up the crontab, be sure it is also running: https://www.cyberciti.biz/faq/howto-check-cronjob-is-running-not/

  • Wow! Thanks! I'll give that a try. It's a bit complicated for me but I'll let you know how it goes.
    – BassPlaya
    Commented Dec 11, 2020 at 0:33
  • One question though: how can I give those 2 different rules each a different cron run time? To me, it seems that if rules_cron is run, it will run "all" scheduled rules, at that specific time. If my thinking is correct, how to overcome that?
    – BassPlaya
    Commented Dec 11, 2020 at 0:39
  • A couple ideas that come to mind are a) to use a condition like "Data comparison" and compare to a field on your entity or b) you might need to write some code. Start with hook_cron_alter().
    – Beau
    Commented Dec 11, 2020 at 18:11

If you want to run the cron hook from an individual module (or any other function for that matter), you can use drush's php-eval function. I have a shell script that does this for one client:

cd /path/to/site/root
drush php-eval 'mymodule_cron()';

Then you just schedule this as you want, for example:

*/2 6-19 * * 1-5 ~/scripts/my_custom_cron.sh

The only thing to be aware of is that mymodule_cron() will also be called by the normal Drupal cron hook if it has the _cron suffix, so you might want to call it something else if you want to avoid that

  • Thank you, James. I love drush but what you're saying just tops my understanding of custom Drupal modules I'm afraid, unless you wouldn't mind spending time to provide an example of a how to create a basic module for these purposes.
    – BassPlaya
    Commented Dec 11, 2020 at 0:43
  • 2
    Basically every module that wants to hook into Drupal's cron process needs to have a function called [mymodule]_cron - all my solution does is call that function. It can in fact be used to call any function that exists in the global scope. But yeah a basic understanding of module dev is probably helpful :-) Commented Jan 5, 2021 at 16:15

Your Answer

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

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