Skip to content
Advertisement

ExpressJS: run a function every 24 hours

What’s the easiest way to run an automated function every 24 hours in ExpressJS?

I have searched everywhere for a solution aside from running an infinite loop. Is this in principle the only way to do it?

Advertisement

Answer

you need to use node-cron npm

var cron = require('node-cron');


cron.schedule('0 0 * * *', () => {
  console.log('running a task every day');
});

get other cron formula :https://crontab.guru/examples.html

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement