Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer

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
Done
$

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
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.