Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

3 Answers

up vote 14 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
add comment

Using the wait command

$ sleep 10 &
[1] 29703
$ wait 29703 && echo hello
[1]+  Done                    sleep 10
hello
share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.