Directories converted into files with the same size

Hi Gurus,

I know this sounds weird, We have encountered many incidents where some directories on several Solaris 10 boxes, will be converted to files with the same size. for example the file below :

-rw-r--r--   1 rkadm    redknee  5027399 Apr 15 00:02 dump

This was a directory created few months back, now We see it as a file created on Apr 15 with the same size of that directory!!

We have the below cron in place, which zip and move files into that direcotry :

30 7,19 * * * /usr/bin/find  /opt/redknee/product/cps/dump/ -type f -mtime +3 | xargs /usr/bin/gzip;/usr/bin/find /opt/redknee/product/cps/dump/ -type f -mtime +3 |xargs -I '{}' mv {}   /er_archive/rkcps1b/cps/2011/dump_back/

Also, When I check the file type I see :

dump:           gzip compressed data - deflate method , original file name

Im suspecting the mv command in the above cronjob, to be replacing the file sometimes with the directory, instead of moving it there.

Has anyone of you come across this before?

Regards
Aladdin

You line of code has problems. If there are odd characters in file names ex:spaces tabs or '\n' it will screw up the result of find and cause your mv to interpret /dump as the name to use as a destination file name.

Have a look here:

ParsingLs - Greg's Wiki

1 Like

An improvement attempt

find /opt/redknee/product/cps/dump/ -type f -mtime +3 -exec gzip {} +; find /opt/redknee/product/cps/dump/ -type f -mtime +3 -exec mv {} /er_archive/rkcps1b/cps/2011/dump_back/ +
1 Like

jim mcnamara,

Thank you for your reply, the issue is this cron has been in place for years, We just notice this incident of directories from time to time ( once every few months), Thank you for the helpful Wiki info as well.

MadeInGermany,

Many thanks for the tips, Im trying to search about the "+" suffix, appreciate if you can provide any hints to look further.

Thanks
Aladdin

The + is an efficient alternative to the \;
The + collects arguments like xargs, so runs the external command (e.g. gzip) less often.
The + works well in Solaris; might not work properly on other OS.

1 Like

aladdin:

In case this task is critical, you may want to be aware that, since find is called twice, it's possible for a file to be moved without being gzip'd. It could happen if a file crosses the -mtime +3 threshold between runs.

Regards,
Alister

1 Like