📜  节点 cron 计划特定时间 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:57.591000             🧑  作者: Mango

代码示例1
const CronJob = require('../lib/cron.js').CronJob;

console.log('Before job instantiation');
let date = new Date();
date.setSeconds(date.getSeconds()+2);
const job = new CronJob(date, function() {
    const d = new Date();
    console.log('Specific date:', date, ', onTick at:', d);
});
console.log('After job instantiation');
job.start();