Originally i want to run cron jobs every morning 6:00AM , so i started testing with below code to run my cron jobs every 5 minutes but i did not see anything in 5 minutes. So my question is what is implemented wrong in below code and how can i implement with specific time ?
cron.js
var cron = require('node-cron');
var fs = require('fs');
var path = require('path');
var async = require('async');
var cronJob = new cron.CronJob('*/5 * * * *', function() {
// read each directory
async.eachSeries(directories, function (dir, cb1) {
var dir = __dirname + dir;
console.log('reading', dir);
// get files for the directory
fs.readdir(dir, function (err, files) {
if (err) return (err);
console.log(files);
compareDates(files);
});
});
});
function compareDates(files) {
// code to run this function
//
}
via hussain
No comments:
Post a Comment