I would recommend node-cron
. It allows to run tasks using Cron patterns e.g.
'* * * * * *' - runs every second
'*/5 * * * * *' - runs every 5 seconds
'10,20,30 * * * * *' - run at 10th, 20th and 30th second of every minute
'0 * * * * *' - runs every minute
'0 0 * * * *' - runs every hour (at 0 minutes and 0 seconds)
But also more complex schedules e.g.
'00 30 11 * * 1-5' - Runs every weekday (Monday through Friday) at 11:30:00 AM. It does not run on Saturday or Sunday.
Sample code: running job every 10 minutes:
var cron = require('cron');
var cronJob = cron.job("0 */10 * * * *", function(){
// perform operation e.g. GET request http.get() etc.
console.info('cron job completed');
});
cronJob.start();
You can find more examples in node-cron wiki
More on cron configuration can be found on cron wiki
I've been using that library in many projects and it does the job. I hope that will help.