Search code examples
javascriptnode.jsnode-cron

Difference between node-cron and setInterval()


I need to repeat a backend task every hour. I've read that node-cron is good for that. But why not just setInterval(). What is the difference?


Solution

  • Using setInterval() only allows you to set a repetition by a fixed value of milliseconds. nothing else.

    With cron-node you are much more flexible, because you can set your interval with the full variety of time parts. Seconds, minutes, hours and so forth. It's a real scheduler.