Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Let's say I've just started a command that will take a long time to execute, like hg clone the entire Pypy development set. Halfway through, I decide I'd like to run another process, like hg up, once the first one returns. Is there a way to attach a command to execute when the process returns, without stopping the command/process and then restarting it as a chained command? command/process?

share|improve this question
up vote 3 down vote accepted

Assuming you're using bash, and assuming you placed the long-running task into the background of the current shell, either by running longtask & or by starting the task then hitting CTRL + Z, then you can add an extra command to run, eg:

$ sleep 45 &
[1] 27722
$ wait 27722 && echo "Done"
[1]+  Done   sleep 45

In the example above, the echo "Done" is only executed after completion of the wait on PID 27722.

The thing I've not found is a way to put this additional command into the background to allow you to carry on working in the same shell. There must be a way to do it though - this should hopefully give you a start.

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.