haifa-reminder/node_modules/cron/examples/object_param.js

24 lines
568 B
JavaScript
Raw Normal View History

2023-07-26 11:01:58 +00:00
const CronJob = require('../lib/cron.js').CronJob;
let isRunning = false;
console.log('Before job instantiation');
const job = new CronJob({
cronTime: '* * * * * *',
onTick: function() {
const d = new Date();
console.log('Check every second:', d, ', isRunning: ', isRunning);
if (!isRunning) {
isRunning = true;
setTimeout(function() {
console.log('Long running onTick complete:', new Date());
isRunning = false;
}, 3000);
console.log('setTimeout triggered:', new Date());
}
}
});
console.log('After job instantiation');
job.start();