Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
I want to save server pressure by only loading an app during business hours.
In order to only load an app during specific times, I exit the script outside the time intervals.
The problem is that all data disappears. Is there any way of exiting the script, retaining the data from the last reload and not getting fail errors in the logs?
Temporarily we decided to via QlikView trigger the Qlik Sense app.
But the suggestion below would be perfect. Please vote if you agree!
https://community.qlik.com/t5/Suggest-an-Idea/Qlik-Sense-task-reload-between-hours/idi-p/1652951
Hi can you please share the script you are using.
SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';
LET vSOBD = NUM(MakeTime(02,00));
LET vCOB = NUM(MakeTime(21,30));
IF (WeekDay(TODAY()) <> 'Sat' AND WeekDay(TODAY()) <> 'Sun') AND (FRAC(Time(NOW())) >= $(vSOBD) AND FRAC(Time(NOW())) <= $(vCOB)) THEN
EXIT SCRIPT;
ELSE
LOAD FAIL FROM ERROR;
END IF;
What if you binary load itself first.
And if condition meets where you are getting new data, drop all tables first (using below) and then do your load script, otherwise exit, but you now would have loaded all data in before exiting.
for i = 0 to NoOfTables()-1
let vTableName = '[' & TableName($(i)) & ']';
drop table $(vTableName) ;
next i
Thanks, but the mail goal is not to load the app at all between 21,30 and 02,00 to save the server....in your example the app loads every time?
Yes but it is a quick reload. If you are trying to control scheduling itself, can't you do this in your Tasks's trigger condition?
A partial workaround for this is:
SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';
LET vSOBD = NUM(MakeTime(02,00));
LET vCOB = NUM(MakeTime(21,30));
IF (WeekDay(TODAY()) <> 'Sat' AND WeekDay(TODAY()) <> 'Sun') AND (FRAC(Time(NOW())) >= $(vSOBD) AND FRAC(Time(NOW())) <= $(vCOB)) THEN
Load FakeField Resident FakeTable;
END IF
This should result in an error any time your condition is true, and unless you're toggled ErrorMode=0, an error should cause the reload task to fail and not replace the existing data. It does mean that this will be listed as a failed reload, though, rather than a successfully completed reload, so it only achieves two of your three goals.
I think you'd need to use some sort of more complex workaround if you want to achieve all three - perhaps you could chain two application reload tasks. The first app would just check the time condition and fail (as above) during the specific times required, and the second task for the actual app being reloaded would trigger off a successful finish of the first app. You could also use an external script with API calls to reload only at specified times, I assume.
One last possible workaround solution - rather than exiting the script, check the time, and if it's within the time frame you want to avoid loading, sleep() for ten minutes and then check again (using a loop) until e.g. 2am is hit and the reload can take place. This will keep the app loading for a long time but it won't cause it to fail and it shouldn't eat up resources.
Thanks for great ideas! Awesome! Sleep especially creative...I wonder if it takes a lot of CPU-usage? Does it lock a CPU?
Temporarily we decided to via QlikView trigger the Qlik Sense app.
But the suggestion below would be perfect. Please vote if you agree!
https://community.qlik.com/t5/Suggest-an-Idea/Qlik-Sense-task-reload-between-hours/idi-p/1652951