Find the answer to your Linux question:
Results 1 to 5 of 5
Simple question. Had a friend who couldn't run Firefox on a college computer for a year, had a look into it and it was an unremoved lock file. How do ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    59

    How do lock files work on Linux?


    Simple question. Had a friend who couldn't run Firefox on a college computer for a year, had a look into it and it was an unremoved lock file. How do these files work that such a problem can come up? Shouldn't they be somehow flagged and removed after a reboot or logoff or is there a similar mechanism that should prevent this?

  2. #2
    Linux User sgosnell's Avatar
    Join Date
    Oct 2010
    Location
    Baja Oklahoma
    Posts
    492
    They should be removed as soon as the app is closed, but sometimes stuff happens, and sometimes it doesn't happen. Once in awhile a lock file just doesn't get removed for some reason.

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,655
    On Linux/Unix systems, file locks are advisory only. An application that uses them often will have an override option to deal with such detritus left behind when the application/server/system crashed, though sometimes you have to manually remove them (the lock files).
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Oct 2009
    Posts
    59
    Was just wondering if there is some kind of flag that makes the file temporary and it will disappear whenever the system reboots. Or the app/system could use ram for lock files - when the system reboots the RAM gets wiped and all locked fill still there errors could be fixed.

  6. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,655
    Quote Originally Posted by SkyHiRider View Post
    Was just wondering if there is some kind of flag that makes the file temporary and it will disappear whenever the system reboots. Or the app/system could use ram for lock files - when the system reboots the RAM gets wiped and all locked fill still there errors could be fixed.
    That's up to the application. There are OS-level locks - in memory only, created with the flock() function - they go away when the system reboots or the application dies. There are file-level locks - a lock file is created - they stay around unless the creating application unlinks them. In theory, if these lock files were created in /tmp, then they should go away upon reboot; however, this is not necessarily the case. I see a lot of files in /tmp that stay around for some time, even between reboots.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •