[CLUE-Tech] Setting up a command to run after another completes
Dale K. Hawkins
dhawkins at cdrgts.com
Wed Jun 9 11:02:14 MDT 2004
On Sun, 2004-06-06 at 21:32 -0600, Chris Greene wrote:
> I'm running a command that has ran for 30 minutes so far and should
> take another 30. After it completes, I need to run another command
> that will be just as long. Given that the first command has already
> started, is there any way I can setup the second command to run as
> soon as the first command is finished? Thanks.
There is a shell one-liner that I like
$ while (ps -C apt-get > /dev/null); do sleep 5; done; echo fini
This will run the echo command within five seconds of the apt-get
command completing. (could be done using pids instead). I've used this
for automatic shutdowns after downloading my upgrades.
The problem is that the above polls (every five seconds) and runs ps.
It might be slightly (ever so slightly) cheaper to
$ while [ -d /proc/28611 ]; do sleep 5; done; echo wheee
Still requires polling...
*pondering whether this could be done using locks and the proc
filesystem. pondering if anyone cares. considering getting back to
real work.*
-Dale
More information about the clue-tech
mailing list