Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script:


env -i
exec ./ Release "${ACTION}"

env -i
exec ./ Debug "${ACTION}"

Second exec does not execute. Why, and how can I execute it?

share|improve this question
up vote 2 down vote accepted

exec will replace the entire process with the contents of the command you're passing in--in this case, Check out the man page for the linux exec function--it explains it in depth.

I assume this is a shell script; if you want the script to simply RUN the other scripts sequentially (one after the other), you'll use:


env -i
./ Release "${ACTION}"
./ Debug "${ACTION}"

This will run ./ Release "${ACTION}" first; after it finishes, it will run ./ Debug "${ACTION}". If you want both commands to run in parallel (at the same time), you can background the process using &.


env -i
./ Release "${ACTION}" &
./ Debug "${ACTION}" &

Keep in mind that background both processes means you'll have two processes running (and outputting!) simultaneously. So if you have logging output, your screen will get messy, to say the least.

Hope this helps!

share|improve this answer
Wow! in parallel! Awesome! Thanks! And additionally, does parallel execution work on all kind of shells? Or specific kind of shells? – Eonil Sep 1 '10 at 15:31
Just about any modern shell you would use will support it; bash, zsh, ksh, etc.. Check out the bash manual topic on job control for some useful tips on using your shell to its fullest! – Andrew M. Sep 2 '10 at 3:05

exec is substituting the current shell by the commands passed. If you want the script to continue, remove the exec statement(s).

share|improve this answer
Is there a way to executing external script without substitution? – Eonil Sep 1 '10 at 14:52
Wow. I understand. I removed exec characters, then it worked. Thanks! – Eonil Sep 1 '10 at 14:58
See my answer for an explanation of why it works. :) – Andrew M. Sep 1 '10 at 14:59

What about adding the "&" character to the end of the line if you want it to run in the background, or "&&" between the first and second statements if you want the second to be conditional on the first being successful?

(My shell-fu is weak, so I'd love to hear why this may be wrong, for educational purposes.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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