1752671 Members
5349 Online
108789 Solutions
New Discussion юеВ

Re: Partial Files ?

 
SOLVED
Go to solution
mike boswell_3
New Member

Partial Files ?


I use scripts to process a pile of files in a directory. I have been doing this on off hours when no one is around. I need to increase the frequency that it is run and will need to run it during business hours.

The senario goes like this. A Pc user w/ a samba connection to the hp-ux machine drops a file into the directory(INBOX). The script on the hp-ux machine is run via cron and moves the accumulated files out the the INBOX.

Could I end up moving a file before it is fully written to the INBOX and end up w/ a partial file? There must be a protection in place against this. Just need to confirm.

Thanks,
Mike B
4 REPLIES 4
Mark Grant
Honored Contributor
Solution

Re: Partial Files ?

Yes you could but it probably doesn't matter.

When you "mv" a file to another location on the same filesystem, the file doesn't change at all and, in fact, doesn't actually move anywhere. If the file is being written to when you "mv" it, it will still be being written to after the "mv".

There are two scenarios where you might hit a problem. Firstly, if your target directory for the INBOX files is on another fileystem then "mv" is just a "cp"+"rm" and then you will lose data from unfinished files.

Also, if, when files are written, the application closes the file and later re-opens it to append data, then, again you run the risk of copying half a file.

I would do some tests but my guess is that you will be OK.

However, if unsure then just play safe.
Never preceed any demonstration with anything more predictive than "watch this"
RAC_1
Honored Contributor

Re: Partial Files ?

On each file you can do fuser/lsof to know, if it is being used by a process or not.


You can also compare the size of the file on Windows to that on the hp-ux

Anil
There is no substitute to HARDWORK
mike boswell_3
New Member

Re: Partial Files ?

Thanks,
That makes me more comfortable.
Mike
harry d brown jr
Honored Contributor

Re: Partial Files ?

Mike,

>>>>The senario goes like this. A Pc user w/ a samba connection to the hp-ux machine drops a file into the directory(INBOX).

How are the files dropped off into "INBOX"? Does the user manually do it or does some application do it?

>>>>The script on the hp-ux machine is run via cron and moves the accumulated files out the the INBOX.

If an application does it, then have the application drop the file off, then have it drop off a file name with a suffix of "RDY" - change your cron script to look for "RDY" suffixes only.

If it is a user manual file movement to "INBOX", then change your script to use "lsof" on the file to make sure no one has it open. lsof: http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.70/

live free or die
harry
Live Free or Die