My question is simple : I have a program written in nodejs and want to run it in an infinite loop in the language bash, is this possible?

2 Answers 2


while true
   node <myapp>

you can also use it as a one liner while true; do; node ; done;


You can run your app in the background like so

$ node app.js &

If you are looking to keep a running node process, though, I would look into the forever package.

$ sudo npm install forever -g
$ cd /path/to/your/project
$ forever start app.js
  • 1
    Yes, I know But for the project I'm doing i needed to run it with bash
    – D4IVT3
    Nov 4, 2015 at 16:44
  • @D4IVT3 - Updated answer. I really wouldn't use a while-true loop because it will lock up your computer infinitely creating node processes. Nov 4, 2015 at 16:48
  • @D4IVT3 - Also, you have node installed and therefore npm, so there is no reason not to use forever to start and monitor your node process. Nov 4, 2015 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .