On Tue, 4 Jan 2005 22:48:22 -0500, Paul W. Abrahams wrote:
Is there lurking somewhere in bash or as a utility program something I can use on a command line to construct a semaphore? The idea is that I have some resource and a couple of processes that want that resource. I want to make sure that if one gets the resource, the other is locked out until the first one is finished.
For what it's worth, here's the specific case I'm interested in. I want to back up my home directory once a day. Easy enough, it seems -- create a cron job that does the deed at noon each day. But what if my machine isn't turned on at noon (since I don't leave it on all the time)? Again -- easy enough: do the backup when the machine is turned on, and set a signal indicating that it's been done. If the signal is set at noon, then don't do the backup.
But things get interesting if I turn the machine on very slightly before noon. Then it's possible that the job will either get done twice or not at all if I don't handle the signal correctly. That's the problem that semaphores are supposed to solve.
Paul
I don't know of one, but you can write your own in c code pretty easily.
#include