ko001 ko001 - 1 month ago 7
Node.js Question

How can i run cron job everyday morning 6.00am?

i have made every minute cron job. but i want cron job to run every day morning 06.00 am and inside cron job i need to search who are all registred yesterday i need to print ?how can i modify my code any one help me out?

cron.schedule('* * * * *', function(){

console.log('running a task every minute');

User.find(condition).sort('-created').populate('user', 'displayName').exec(function(err, user)
{


});
});

Answer

To run everyday on 6.00am simply use

cron.schedule('0 6 * * *', function(){
  console.log('running a task at 6am');
});
Comments