Picture of Tobias 1810
Registered 10 years 327 days
Tobias 1810 Wednesday, 3 April 2024, 04:31 PM
How to execute tasks like “cronjobs” in JavaScript for App Services?

Is there a way to execute tasks or specific code to a specific date and time in JavaScript for App Services? Something like “cronjobs”?

Picture of Matthias Schertler (innovaphone)
Moderator Registered 12 years 191 days
Matthias Schertler (innovaphone) Thursday, 4 April 2024, 09:00 AM
2 of 2 users consider this post helpful
Re: How to execute tasks like “cronjobs” in JavaScript for App Services?
Hi Tobias,

currently there is no possibility to get a callback at a specific time.

I'd recommend to start an interval that fires each minute or each five minutes and use it to check if the time for the job has been reached.

Maybe something like that:

function callbackTime(executionTime, callback) {
// intervall that fires each minute
var i = Timers.setInterval(check, 60000);

function check() {
// check if execution time has been reached
if (new Date() >= executionTime) {
Timers.clearInterval(i);
callback();
}
}
}

BR
Matthias
← You can define your color theme preference here