RE: [SLE] Command-line semaphores
You could touch a file out to /var/lock and have the process check for the lock file then cleanup when you are ready to proceed.
-----Original Message----- From: Paul W. Abrahams [mailto:abrahams@acm.org] Sent: Tuesday, January 04, 2005 7:48 PM To: suse-linux-e@suse.com Subject: [SLE] Command-line semaphores
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
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
participants (1)
-
Michael Benz