Friday, 12 May 2017

How to run mongoose query in cron job?

try {
var cronDo = new CronJob({ cronTime: '* * * * * *', onTick: function() { user.find({},function(err,doc){ console.log("--------------testing-----------");

          });              
        },
        start: false,
        timeZone: 'America/Los_Angeles'
      });
    cronDo.start();

} catch(ex) {
    console.log("cron pattern not valid");
} 

what is wrong in my code ? I am not getting any output. while If I remove mongo's part then cron is giving output.



via uday karn

No comments:

Post a Comment