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();
}
}
}
// 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