itamar itamar - 1 year ago 121
Javascript Question

Later.js execute Function on Schedule?

I am going through the Later.js docs and it documents how to set the schedule very well - but doesn't show how to execute the function once you've done so.

So if I have

function logit(){
console.log('it is done');

And I want it to run once a day - Where in here do I inject logit?:

var cron = '15 10 * * ? *';
var s = later.parse.cron(cron);


Answer Source

You need to use the setInterval and setTimeout functions to execute code with schedule:

later.setInterval(logit, s);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download