Defining a precise time for a $Rule to be executed

I’m wondering if this approach is effective and not resource intensive: imagine I don’t want:

  • a complex set of rules to be executed continuously (hangs things);
  • to execute that set of rules with a stamp (I’m lazy and forget things);
  • to use an edict;

How about defining a rule as this:

if (time(today).minute == 5 | time(today).minute == 10 | time(today).minute == 15 | time(today).minute == 20 | time(today).minute == 25 | time(today).minute == 30 | time(today).minute == 35 | time(today).minute == 40 | time(today).minute == 45 | time(today).minute == 55) {$Text="Current minute is multiple of 5";} else {$Text = "Current minute is NOT multiple of 5";};

(sorry for the lazy code – there must be a simpler way of writing it)

This can make a complex set of rules to execute if the current minute in the system clock is multiple of 5 – i.e. executes every 5 minutes.

We could make a rule execute every 5 minutes, ever hour, etc …

Can this help save cpu resources? Is there anything similar in TBX by default which I’m not aware of? Thanks!

This is interesting and there are people who will know 100% (I don’t!) but my first thought is that this rule would evaluate the “if” on the regular schedule but produce a “true” result only at five minute intervals. Curious what the real answer is…

Have you looked at Edicts? An edicts is essentially a low priority rule. It covers the scenario where you need a rule (e.g. to do something you might forget) but doesn’t need to run all the time. Edicts can also be run on demand so if you know they need running to update something and can’t wait you can force an update.

Or, is the issue you need to control the exact time at which a rule is run?

Just curious – but what are you doing that requires Tinderbox to be a clock? Is it something that might happen better in the shell and use runCommand in the rule rather than all that logic?

1 Like

Thanks Brian, Mark and Paul for the replies. This is just me trying to know how far I could get with TBX with this in mind (and if it could bring me problems in the long run if I abused this kind of mechanism). I don’t have a particular problem that requires this; and I’m very happy with edicts since they trigger when something changes (perhaps it would be nice yet another addict that could trigger immediately after selecting a note). runCommand/osascript is on my hit list of things to learn – my knowledge of applescript is a bit rudimentary but thanks!