run process daily on random times 4 times

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
swiftinitpvtltd
Posts: 370
Joined: Sat Apr 28, 2018 3:33 am
Location: India
Contact:

run process daily on random times 4 times

Post by swiftinitpvtltd »

If I need to run the process daily on random times 4 times how do I randomness to the 4 times run.
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: run process daily on random times 4 times

Post by tford »

Maybe you could schedule a process to run many more times per day, but have the process first check a SystemSettings that could control the randomness & whether the process should run at that time or not. Just a thought. I don't have further ideas about how that SystemSettings process would work though.
Tom - V8.8 build 3137 - MySql / PostGres
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: run process daily on random times 4 times

Post by joben »

I think tford's approach is worth trying.

I would create 4 attributes in SystemSettings like "RandomTime1", "RandomTime2", "RandomTime3", RandomTime4".
Then run a process once a day at 00:00 that randomizes the value for each attribute that can be interpreted as a time.

Then schedule another process with something like:

Code: Select all

If CURRENT_TIME=SystemSettings.RandomTime1 OR CURRENT_TIME=SystemSettings.RandomTime2 OR  CURRENT_TIME=SystemSettings.RandomTime3 OR CURRENT_TIME=SystemSettings.RandomTime4 Then ProcessName
Regards, Joakim

Image
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: run process daily on random times 4 times

Post by BobK »

joben wrote:I think tford's approach is worth trying.

I would create 4 attributes in SystemSettings like "RandomTime1", "RandomTime2", "RandomTime3", RandomTime4".
Then run a process once a day at 00:00 that randomizes the value for each attribute that can be interpreted as a time.

Then schedule another process with something like:

Code: Select all

If CURRENT_TIME=SystemSettings.RandomTime1 OR CURRENT_TIME=SystemSettings.RandomTime2 OR  CURRENT_TIME=SystemSettings.RandomTime3 OR CURRENT_TIME=SystemSettings.RandomTime4 Then ProcessName
Like joben said, almost.

First off, the time function is CURRENT_TIMESTAMP not CURRENT_TIME

Secondly, the rules in the Schedule are processed approximately once every 60 seconds. But there is no guarantee on what second your rules will be processed. It is unlikely that when your rules are evaluated the RandomTime would equal the CURRENT_TIMESTAMP down to the second.

What I would do is, besides the 4 RandomTime fields, create 4 Yes/No fields. These could be called something like Random1Processed, Random2Processed, Random3Processed, Random4Processed.

Your process run at 00:00 would set the 4 Yes/No fields to No.

I would also break out the rule that checks the times into 4 separate rule, each one like this:

Code: Select all

If CURRENT_TIMESTAMP >= SystemSettings.RandomTime1 AND Random1Processed='No' Then
 Random1Processed='Yes'
 ProcessName
Bob
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: run process daily on random times 4 times

Post by joben »

BobK wrote: Like joben said, almost.

First off, the time function is CURRENT_TIMESTAMP not CURRENT_TIME
In the scheduler, CURRENT_TIME is used as default rather than CURRENT_TIMESTAMP. At least in the BSV I used as reference.
Regards, Joakim

Image
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: run process daily on random times 4 times

Post by BobK »

Well whadya know, there is a CURRENT_TIME function.
I stand corrected.
I learn something new everyday.

And CURRENT_TIME does not contain seconds, so I guess my second point is not entirely accurate either.
Bob
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: run process daily on random times 4 times

Post by joben »

BobK wrote:Well whadya know, there is a CURRENT_TIME function.
I stand corrected.
I learn something new everyday.

And CURRENT_TIME does not contain seconds, so I guess my second point is not entirely accurate either.
:wink:

To be honest, I wasn't aware of CURRENT_TIME until recently when I fiddled around with schedules to make them run more frequently than what is currently possible when using the Standard View. However, I still ended up using CURRENT_TIMESTAMP instead.

Here is one example how to check every 10 mins if there are any urgent jobs that should be sent via email:

Code: Select all

If 

(MINUTE(CURRENT_TIMESTAMP)=00 OR
MINUTE(CURRENT_TIMESTAMP)=10 OR
MINUTE(CURRENT_TIMESTAMP)=20 OR
MINUTE(CURRENT_TIMESTAMP)=30 OR
MINUTE(CURRENT_TIMESTAMP)=40 OR
MINUTE(CURRENT_TIMESTAMP)=50) AND CURRENT_DATE>=21/04/2020
Then Send_email_if_exists_urgent_jobs
I hope swiftinitpvtltd will find some inspiration from our different approaches to complete the task!
Regards, Joakim

Image
Post Reply