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.

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks T.J. I have already created the windows scheduler, I have to look at the run it as a service.
0

Please have a look at foreverjs

https://github.com/foreverjs/forever

I found it very flexible and reliable.

2 Comments

Looks like, this forever js works for linux, is it available for windows also?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.