Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

Sometimes I start a program that takes a very long time to finish (emerge), then realize that I should go to bed instead of waiting for it. If I know this in the first place I would run

program; halt

However, now that I have started the program already, how can I "schedule" the computer to shutdown when that process finishes? Would Ctrl+z then fg; halt be OK?

share|improve this question
up vote 15 down vote accepted

Yes, that would work.

If unsure, you may test it with

  • sleep 15

  • Ctrl+z

  • fg; echo "it works"

share|improve this answer
thanks, and btw the test is handy :) – phunehehe Oct 1 '10 at 19:10

Another way is to just type halt in your terminal while the first command is running; as long as the first command doesn't read input at some point it will sit in the terminal's buffer and the shell will read it when the first program ends

share|improve this answer

Using the wait command

$ sleep 10 &
[1] 29703
$ wait 29703 && echo hello
[1]+  Done                    sleep 10
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.