0

I am new to node.js I have question about how to run mulitple files at once. let's say I have scripts_1.js and scripts_2.js How can I run the both at the same time. I know I can do this node scripts_1.js && scripts_2.js but the problem is that I need to wait for scripts_1 to finish so scripts_2.js can run.

I tried bash scripts start.sh

start node "scripts_1.js"
start node "scripts_2.js"

but I don't like it I need a better way. any one can help. Thanks in advance

5
  • What about node scripts_1.js && node scripts_2.js? That should wait for the first node execution to finish before the second. Commented Jun 6, 2020 at 14:32
  • Yes, but I don't want that I want the both to run at the same time Commented Jun 6, 2020 at 14:37
  • Oh, then just use one ampersand: node scripts_1.js & node scripts_2.js Commented Jun 6, 2020 at 14:38
  • is this work too with python, like python scripts_1.py & python scriopts_2.py ? Commented Jun 6, 2020 at 15:44
  • yeah, it's shell scripting so it doesn't matter what you're calling from shell Commented Jun 6, 2020 at 16:04

1 Answer 1

1

You can run multiple commands asynchronously by separating them with one ampersand in shell:

node scripts_1.js & node scripts_2.js
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.