Answer the question
In order to leave comments, you need to log in
How to run a script every 5 minutes in node.js?
Greetings.
There is an application on node.js + express 4.0. Inside the application there is a parser that must be constantly launched after a certain period of time (let's say 5 minutes).
How to implement this in node.js?
PS The first thought was to simply wrap the parser call in setTimeout, but I'm not sure if this is a good solution.
Answer the question
In order to leave comments, you need to log in
1. Crontab: */5 * * * * /script.sh and run node script.js in the script
2. Do require('child_process').fork('script.js'); and already in script.js do setTimeout
3. Use ready-made solutions from npm, for example node-schedule , node-crontab
setTimeout is a completely normal solution, I did this even for almost daily calls, no problems. Native, simple and reliable.
Can you please explain to me why setTimeout is not a good solution? I will be very grateful!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question