Skip to content

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?



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 :

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