admin管理员组文章数量:1389772
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);
later.schedule(s).next(10);
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);
later.schedule(s).next(10);
Share
Improve this question
asked Mar 12, 2015 at 13:57
itamaritamar
3,9675 gold badges36 silver badges60 bronze badges
2 Answers
Reset to default 4Their documentation does not make this very clear, but later.setInterval
takes a schedule as it's second argument.
The examples for this usage are available at http://bunkat.github.io/later/execute.html
so to plete your example,
function logit(){
console.log('it is done');
}
var cron = '15 10 * * ? *';
var s = later.parse.cron(cron);
later.setInterval(logit, s);
hope this helps.
You need to use the setInterval and setTimeout functions to execute code with schedule:
later.setInterval(logit, s);
本文标签: javascriptLaterjs execute Function on ScheduleStack Overflow
版权声明:本文标题:javascript - Later.js execute Function on Schedule? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744669785a2618756.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论