Directories converted into files with the same size


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Directories converted into files with the same size
# 1  
Old 04-19-2013
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 :

Code:
-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 :

Code:
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 :

Code:
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
# 2  
Old 04-20-2013
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

Last edited by jim mcnamara; 04-21-2013 at 08:55 PM..
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 04-21-2013
An improvement attempt
Code:
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/ +

This User Gave Thanks to MadeInGermany For This Post:
# 4  
Old 04-21-2013
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
# 5  
Old 04-21-2013
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.
This User Gave Thanks to MadeInGermany For This Post:
# 6  
Old 04-21-2013
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
This User Gave Thanks to alister For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

2. Shell Programming and Scripting

Directories above particular size

Hi guys, i'm searching for a command, which gives me back all the directories which are greater than a particular size? thx for helping so far :b: guti (2 Replies)
Discussion started by: guti_rocks
2 Replies

3. UNIX for Dummies Questions & Answers

Finding size of all directories

Alright so I've tried a couple different things that at first glance, looked like they worked. find . -maxdepth 5 -type d -daystart -mtime 1 | xargs du -h Which seems to ignore the previous commands such as depth and modified time. find .. -maxdepth 2 -type d -daystart -ctime 1 | xargs... (8 Replies)
Discussion started by: Aussiemick
8 Replies

4. Shell Programming and Scripting

How to list all the directories, sub directories in a mount along with size in ascending order?

Hi , I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In a particular mount, have to list all the directories and sub directories along with size of the directory and sub directory in ascending order. Please help me in this regard and many... (4 Replies)
Discussion started by: nmakkena
4 Replies

5. Shell Programming and Scripting

checkingthe size of all the .txt , .ext files in all directories ..

hai, i am new to unix scripting & learning unix scripting and doing some assignments.... i have an assignment as follows, i want to check the size of the text file and .ext files in all directories, if any one of them is greater than 100mb , i have to display those files.. ... (2 Replies)
Discussion started by: G.K.K
2 Replies

6. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies

7. UNIX for Dummies Questions & Answers

Empty directories having different size

$ls -lrt mydir total 12 drwxrwxrwx 2 nobody nobody 512 Aug 8 11:51 tmp drwxrwxrwx 2 nobody nobody 4608 Jan 19 12:20 web.cache $ ls -lrt mydir/web.cache/ total 0 $ ls -lrt mydir/tmp/ total 0 Can anyone explain me the above results? I know the o/p of ls, but this... (3 Replies)
Discussion started by: rahulrathod
3 Replies

8. HP-UX

Directories Size

Hi All I want to plan my backups, but 1st i would like to know what is the size of each directory. Is there any command which can show me the size of directories? Regards (2 Replies)
Discussion started by: cgege
2 Replies

9. Windows & DOS: Issues & Discussions

RTF files can they be converted once they are on linux system

:D mount -t vfat /dev/hda1 /mnt my dillemma is simple i have psion 5 mx wich is an epoc type machine not only does it only work on windows as far as I know but I have to convert the files (the usual stuff!) sometimes a humen error happens and the files that I want to transfer to the linux drive... (7 Replies)
Discussion started by: moxxx68
7 Replies
Login or Register to Ask a Question