Sounds like I want something like dpkg's deferred triggers, right? pretty much so.
With this need, deferred-run was born. Example:
$ deferred-run -l lock -- echo hello world $ deferred-run -l lock -- echo hello world $ sleep 3 $ deferred-run -l lock -- echo hello world [some seconds later...] hello world
In spite of multiple calls, echo was only called once.
Best part, it only requires sh and flock.
If you are interested in shell trickery, you should take a look at its code.
This script would be a great addition to the moreutils package!
ReplyDelete