ExpressJS: run a function every 24 hours

后端 未结 2 2000
孤街浪徒
孤街浪徒 2021-01-29 15:20

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

2条回答
  •  别那么骄傲
    2021-01-29 15:42

    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

提交回复
热议问题