Tuesday, 4 April 2017

How to use correct format of specific time using node schedule?

With below code i want to run node schedule task every morning 8AM it happens only first time when i start app but next day its not running schedule. what would be correct format to use if i want to execute 8AM or 2PM. Thanks in advance.

cron.js

module.exports = function CronJob() {
    cronSchedule.scheduleJob('08 * * *', function() {
    console.log('Testing 8AM');
            async.eachSeries(directories, function (dir, cb1) {
                var dir = __dirname + dir;
                // get files for the directory
                fs.readdir(dir, function (err, files) {
                    if (err) return cb1(err);

                    // loop through each file
                    async.eachSeries(files, function (file, cb2) {
                        var filePath = path.resolve(dir + '/' + file);
                        // get info for the file
                        fs.stat(filePath, function (err, stats) {
                            if (err) return cb2(err);
                            var fileInfo = { fileDate: stats.birthtime, filename: file };
                            compareDates(fileInfo, filePath);
                            cb2(null, fileInfo);
                        });
                    }, cb1);

                });
            }, function (err, fileInfos) {
                if (err) {
                    console.info('error', err);
                    return;
                }
            });
    });
}



via hussain

No comments:

Post a Comment