[Samba] Can Samba lock files until copy is complete?

Whit Blauvelt whit+samba at transpect.com
Sat Aug 21 07:12:32 MDT 2010

On Sat, Aug 21, 2010 at 02:17:08PM +0200, Michael Wood wrote:

> I think the simplest way to do this, if you have some control over the
> clients, is to get them to upload to a temporary name and rename to
> the real name once the upload has completed.  Then get the process
> that looks for files to ignore the ones with the temporary names.

We'd though of that, but the staff is so used to drag-and-drop file
operations, and also needs to have the share open to see what other staff
has already put there. So if we had the share read-only and gave an icon to
drop the files on that runs a script ... but staff performs under time
pressure, and is set in their method.

> If you can't control the filenames, try using something like incron to
> process the files only when they have been closed.  Or use lsof to
> check if samba still has the files open.  I don't know how reliable
> that will be, but perhaps it's another heuristic to add to your "not
> changed size for a while" check.

incron? Don't know/can't find it. Good suggestion on lsof. If it turns out
that Samba doesn't do anything strange like close a file at an intermediate
state, then reopen and resume copying that might work perfectly.


More information about the samba mailing list