run process daily on random times 4 times
-
- Posts: 370
- Joined: Sat Apr 28, 2018 3:33 am
- Location: India
- Contact:
run process daily on random times 4 times
If I need to run the process daily on random times 4 times how do I randomness to the 4 times run.
Re: run process daily on random times 4 times
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
Re: run process daily on random times 4 times
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:
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
Re: run process daily on random times 4 times
Like joben said, almost.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
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
Re: run process daily on random times 4 times
In the scheduler, CURRENT_TIME is used as default rather than CURRENT_TIMESTAMP. At least in the BSV I used as reference.BobK wrote: Like joben said, almost.
First off, the time function is CURRENT_TIMESTAMP not CURRENT_TIME
Re: run process daily on random times 4 times
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.
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
Re: run process daily on random times 4 times
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.
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