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
JavaScript
x
7
1
var cron = require('node-cron');
2
3
4
cron.schedule('0 0 * * *', () => {
5
console.log('running a task every day');
6
});
7
get other cron formula :https://crontab.guru/examples.html