lock_unlock - creating and removing a lock file

Wednesday, 18 February 2004, 11:46 AM EST

At some point, every shell programmer must ensure that only one process executes at a given time or otherwise ensures a resource is locked.

Often, it's necessary to prevent more than one instance of the same (or related) programs from running at the same time. For example, you may have daily Oracle open backup, and hourly Oracle archive log backup. Both backups save archived logs and delete them. You do not want two instances to run at the same time, creating unpreditable results.

The idiom to do this in shell is to create a lock file or directory. Whatever instance sets the lock first is authorized to proceed. If another instance executes, but a lock exists, the first instance will either wait for the lock to lift or terminate. When the first instance completes execution, it then removes the lock file, so the next instance can run.

By Michael Wang at Unix Review.

[ Read more ]

Related items




Spotlight

USBdriveby: Compromising computers with a $20 microcontroller

Posted on 19 December 2014.  |  Security researcher Samy Kamkar has devised a fast and easy way to compromise an unlocked computer and open a backdoor on it: a simple and cheap ($20) pre-programmed Teensy microcontroller.


Weekly newsletter

Reading our newsletter every Monday will keep you up-to-date with security news.
  



Daily digest

Receive a daily digest of the latest security news.
  
DON'T
MISS

Fri, Dec 19th
    COPYRIGHT 1998-2014 BY HELP NET SECURITY.   // READ OUR PRIVACY POLICY // ABOUT US // ADVERTISE //