Find the answer to your Linux question:
Results 1 to 4 of 4
Hi I've searched all over the web on this but there's surprisingly little help out there. I have an Ubuntu server and Ubuntu clients (all version 8.04). The Ubuntu server ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! beaker15's Avatar
    Join Date
    Sep 2007
    Posts
    30

    locking files (documents) when in use on a linux server/client network


    Hi

    I've searched all over the web on this but there's surprisingly little help out there.

    I have an Ubuntu server and Ubuntu clients (all version 8.04). The Ubuntu server exports NFS shares which i can successfully mount on the clients via NFSv4 without a problem but the problem is when two users open the same openoffice file on the share, they can both open and edit it at the same time without warning, obviously this is not good.

    How do i get the documents to lock when in use by another user?

    Surely I'm not the only person to have a network with linux server and clients that needs documents to lock when in use! How have some of you other people managed it?

    thanks

  2. #2
    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,525
    Linux does not lock files like Windoze does when they are opened by more than one application or user at the same time. This is not an NFS issue. The application that uses them has to issue a lock, or the user has to execute the edit command in conjunction with the flock command. See the flock man page for details. In any case, you should be able to script this easily enough.

    FWIW, both the command and the C function are named flock. If you want the API call man page, it is in section 2: man 2 flock
    whereas the flock system command is in section 1. Also, there is the POSIX lockf() function call, which is similar to flock(2). The flock(2) man page says that it won't work on NFS volumes, but that should not be relevant to the flock(1) system command. At least its man page says nothing about that. The lockf man page says nothing about NFS either.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined! beaker15's Avatar
    Join Date
    Sep 2007
    Posts
    30
    thanks for pointing me in the right direction on this. So if i want open office to lock the document that it has open then I need to make changes to the code of the executable file on every client on the network? if thats the case thats quite disappointing i have to say, surely this is a common issue for a linux network

    thank again for the help

  4. #4
    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,525
    Quote Originally Posted by beaker15 View Post
    thanks for pointing me in the right direction on this. So if i want open office to lock the document that it has open then I need to make changes to the code of the executable file on every client on the network? if thats the case thats quite disappointing i have to say, surely this is a common issue for a linux network

    thank again for the help
    Using the shell flock command, you can "wrap" your open office writer in a script that does the file lock for you. That would work as long as everyone used the script, but someone who didn't would likely not know it was locked. Caveat User! Sorry, but for right now, that's the best idea I can come up with.
    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
  •