简体   繁体   English

节点计划不适用于express.js

[英]node-schedule not working with express.js

I am trying to get node-schedule working with express.js with not luck 我正在尝试让Express.js的节点计划工作不顺利

I'm not sure why this is not triggering ? 我不确定为什么没有触发?

here is my code 这是我的代码

var schedule          = require('node-schedule');

var rule = new schedule.RecurrenceRule();
rule.minute = new schedule.Range(0, 59, 5);


schedule.scheduleJob(rule, function(){
    console.log(rule);
    console.log('Hi---------------------------');
});
var rand = require('randomstring');    
var jobId = rand.generate(10); //randomsrting
var at = new Date();
var time = at.setSeconds(at.getSeconds() + Number(5))  //after 5 second     
schedule.scheduleJob(jobId, new Date(time),function(){
     schedule.cancelJob(jobId);
     console.log('hi--viral');
 });

Sorry, this does work 抱歉,这确实有效

I hadn't waited long enough 我没有等很久

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM