I want to run my node app in background and curl simultaneously using &&. I tried the following but they don't work.

node app.js &;curl localhost
node app.js & && curl localhost

But neither work.

  • 5
    Why exactly do you need &&? That's used when you want the second command to run if the first succeeded - and since you're not waiting for the first to end, that doesn't make sense
    – muru
    Jun 8, 2016 at 16:20
  • 3
    I don't think the question makes sense. (Please explain if you think I am wrong.) You may not understand what && does. The shell is going to make a judgement as to whether the first process runs successfully or not, and if it was successful, run the second. It does this based on the exit status of the first process. If you background the process, you do not know the exit status yet. The answer below, using & will appear to work, but try testing with a first process that fails and gives a non-zero exit status. I expect you will find the curl still runs. Please ponder exit status && and || Jun 8, 2016 at 16:50

1 Answer 1


It's just :

node app.js & curl localhost
  • yeah awesome, really works fine.but how " & "worked two function like this
    – SuperKrish
    Jun 8, 2016 at 13:45
  • Basically, bash looks for the & after running the command, and if it finds it, it starts a concurrent thread running the second command.
    – anonymous2
    Jun 8, 2016 at 13:52
  • 2
    @P.G.Krish If this post solved your questions, please upvote and mark it as the answer to your question. & means put the preceding command in the background while && means run first command and if it succeeds run the second.
    – Ron
    Jun 8, 2016 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.