Function that runs on scheduled time

Asked

Viewed 44 times

1

How to create a function that runs for example every 5 minutes in the nodejs.

I found the lib: http://bunkat.github.io/later but I don’t know how I make it to be executed always, and not just once

  • Maybe you can be whatever you want; http://stackoverflow.com/questions/14868590/setting-a-timer-in-node-js

1 answer

0

I use the lib cron and has worked very well.

But you can also do this with pure Javascript, just use the function setInternal.

setInterval(function () { 
  console.log('Isto aqui vai ser executado a cada 5 minutos'); 
}, 5 * 60 * 1000); //300.000, o que corresponde a 5 minutos

Browser other questions tagged

You are not signed in. Login or sign up in order to post.