Download & Extend

How to periodically execute a rule?

Project:Rules
Version:6.x-1.0
Component:Scheduler
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hi,
Thanks for a great module!

I'm hoping to use Rules to periodically (e.g. every day at midnight or 6pm or whatever time) evaluate a condition (most likely expressed through my own custom PHP code) and when true, have the configured action(s) executed.
Is there a way to do this using Rules + Rules Scheduler?

I guess a possible implementation of this would be via some special action that re-schedules the triggered rule that is part of, for a later time, e.g. 24 hours into the future?
But I'm not sure if I can do this with Rules or how...
Another difference compared to a normal triggered rule would be, I think, that in this case there isn't a normal event as such triggering the process, other than "it is now time (e.g. 6pm)" to evaluate the condition.

Thanks for your time!

Comments

#1

Status:active» fixed

>Rules + Rules Scheduler
Yep it is. In the scheduled rule set, just configure an action that schedules the set again, e.g. 1 day later. So it's getting scheduled each day. Of course only let this action fire, when you want to continue scheduling this set.

#2

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#3

Status:closed (fixed)» active

I could really use some help with this. Here's what I need to do: Every year after a user creates a node he or she will receive an email. I managed to set this up now, but it only fires once. How can I reschedule this?

For testing purposes (since I don't wanna wait a whole year to try this out ;)) I am using this as my scheduled evaluation date:

<?php echo time() + 60 * 1; ?>

I also tried to create a rule set without arguments so I can use the manual scheduling at admin/rules/rule_sets/scheduling because I read somewhere that those automatically reschedule themselves. This works a couple of times and then it's gone.

The last thing I tried was to schedule within the rule of my rule set and then use a rule to schedule the rule set. That only gives me the email once though.

Is what I'm trying to do possible at all?

#4

There is a tutorial for re-scheduling and scheduling loops: http://drupal.org/node/520016

#5

I went through that but in the tutorial they publish and unpublish a node and that's how the loop works (at least that's how I understood it). I don't do that so I have nothing to do my action against. A friend recommended using flag module, that way I could use a similar way described in the tutorial. I thought somebody here would have an idea that I didn't think of.

#6

Status:active» fixed

You simply schedule the set again from a rule inside the set.

#7

Status:fixed» closed (fixed)

"simply" is good :)

I received some help from a friend. Here's an export of my solution for others who need this: http://pastebin.com/y2e1ZMr6 I kept it very general so people can just import it and change it to meet their needs.