0

I know we can run a node.js file in windows via the command prompt like below

cd c:\wamp\www\myfolder
c:\wamp\www\myfolder>node testing.js

My question is, How can I automate this file to run indefinitely for every 10 second or 1 minute in windows?

As of now I have created a scheduler in windows system which is running every 1 minute to execute my js file. I have created a .bat file with required commands and put it in the scheduler. So it is running perfectly. I want to know, are there any other best solutions available?

One more question I have is, every time I run "node testing.js" command, does node js will create a new server instance or will it use the same / old instance which is created earlier. What is the mechanism behind that.

Kiran
  • 1,177
  • 4
  • 18
  • 35

2 Answers2

3

How can I automate this file to run indefinitely for every 10 second or 1 minute in windows?

You can use Windows' task scheduler to do that. It has both a UI and an API.

Alternately, rather than running every 10 seconds, you might run it as a service.

Community
  • 1
  • 1
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • Thanks T.J. I have already created the windows scheduler, I have to look at the run it as a service. – Kiran Apr 22 '15 at 09:56
0

Please have a look at foreverjs

https://github.com/foreverjs/forever

I found it very flexible and reliable.

solick
  • 2,325
  • 3
  • 17
  • 29
  • Looks like, this forever js works for linux, is it available for windows also? – Kiran Apr 22 '15 at 09:55
  • I use it under linux and mac, it is a node application therefore it should also work with windows. EDIT: According to the github issue track it should work in actual version under windows. – solick Apr 22 '15 at 10:01