How to ignore incomplete files

On Solaris, suppose there is a directory 'dir'.
Log files of size approx 1MB are continuously being
deposited here by scp command. I have a script that scans
this dir every 5 mins and moves away the log files that
have been deposited so far.

How do I design my script so that I pick up *only* those
files that have been completely deposited. For example,

[/mylogs] $ ls -l
-rwxr-xr-x 1 root bin 1124124 Jan 9 02:26 log3225
-rwxr-xr-x 1 root bin 1092534 Jan 9 02:33 log3228
-rwxr-xr-x 1 root bin 1130932 Jan 9 02:39 log3230
-rwxr-xr-x 1 root bin 369644 Jan 9 02:46 log3235

the file 'log3235' has not completely been deposited yet.

  • We are using rsync to syncronise this directory to another 4 server, we don't want to copy the incomplete list. Is there any way to ignore those.

Any help will be much appreciated.

Kind Regards

if you are on solaris 9 or newer have a look at the "logadm" command. might be usefull!

how do you know which file ist NOT completley deposited?

You'd need to determine what constitutes a "completely deposited" file, and this needs to be true of all files. Is there some text string that's added to the end of each file you can look for? Sizes and times vary according to your output, so using that wouldn't be accurate.

As it is explained, the only way I see this can be accomplished with the greatest degreee of accuracy, is if you simply copy all files but the last one in the output of

ls -lt

If your archiving something like /var/log you might use something like logrotate and then rsync all the rotated logs.

or find all files that are mtime an hour or more ago

Many thanks for all your replies. Really appreciate your response.

Is there a way in rsync to ignore incomple files?

how will rsync know the file is incomplete?

Suppose you log files are in the directory /dir1.

Move those files which are completely deposited to /dir2.

rsync /dir2

To find out which files are completely deposited use:

fuser /dir1/*