[lug] how to handle open files - upload server
Dan Ferris
dan at ferrises.com
Tue Jan 13 10:27:26 MST 2004
lsof +f -- /directory/to/uploaded/files ?
Nate Duehr wrote:
> [Sorry about the cross-post for those on all the lists, just attempting to
> cover a wider audience.]
>
> Here's an interesting one, or maybe I'm just not creative enough today. I
> have a Linux server where people upload some files to me for processing
> (using sftp). The files show up, I move them to another machine to do
> the dirty work. Simple, right? Move those files elsewhere after they
> arrive, which can pretty easily be done from a cron job, no problem
> there.
>
> The case I'm wondering about: How to detect in that regular cron job if
> the file is open (and probably growing) right at the time because it's
> being uploaded right then... so the cron doesn't attempt to move it to
> the other machine in the middle of an upload.
>
> I'm thinking some silly hack at the top of the "move to other machine"
> script that would look at the directory contents with lsof to make sure
> nothing has any of the files to be moved already open. Is there a
> simpler/smarter way?
>
> (Off to go find some more coffee and think about this some more...)
>
> Bright ideas appreciated! ;-) (No, NFS mounting the other machine and
> having them send directly to it is not an option. ;-) )
>
More information about the LUG
mailing list