Operating System - HP-UX
1827293 Members
1581 Online
109717 Solutions
New Discussion

Re: How to delete massive amount of zero byte files

 
SOLVED
Go to solution
Sandra Nelson_1
Frequent Advisor

How to delete massive amount of zero byte files

I am trying to do some clean up on our db to reduce our backup time. I've found that there are hundreds of thousands of zero byte files that were created and are not needed. The reason these files were created has been resolved, however now I need to delete only the zero byte files from /common/out and /common/log with out removing all the other files houses that are needed. I have no expertise other than to rm each, one at a time. Any help would be appreciated, as we are anxious to reduce our backup time by the elimination of these unnecessary files.

Thanks.
11 REPLIES 11
S.K. Chan
Honored Contributor

Re: How to delete massive amount of zero byte files

This ought to do it ..
# find /common/out -type f -size 0c | xargs rm -f
OR
# find /common/out -type f -size 0c -exec rm -f {} \;
repeat for "/common/log". You might want to test it first by replacing "rm -f" with "ls -l" first to make sure it's listing zero size files.
S.K. Chan
Honored Contributor

Re: How to delete massive amount of zero byte files

I forgot to mention .. if you're NOT running 11.x, you could be getting this error .."arg list too long" if the argument (number of files) limit is reached. If you get this error after the command is run, goto SAM and change the kernel parameter "large_ncargs_enabled" to 1 and run the command again. This only applies to 10.x system, on 11.x this limit has been increased.
Sandra Nelson_1
Frequent Advisor

Re: How to delete massive amount of zero byte files

Thanks for the "ls -l" option as I tried find /common/out -type f -size 0c | xargs ls -l and the output contained all files, not just zero byte.

When I try the 2nd command you shared, it doesn't complete. appldevl@dbserv1:/u001/app/appldevl/appltop/common/out>find /common/out -type f -size 0c -exec ls -l {} \;
find: cannot stat /common/out


We are running 11.0.
harry d brown jr
Honored Contributor

Re: How to delete massive amount of zero byte files

Are you logged in as root?

Is /common/out an NFS mount?

live free or die
harry
Live Free or Die
Sandra Nelson_1
Frequent Advisor

Re: How to delete massive amount of zero byte files

No, was not logged in as root. But tested the command from root and the result is the same as from appldevl, the owner of the files.

find: cannot stat /common/out is the return whether I'm @ / as root, or @ /u001/app/appldevl/appltop/common/out as root

I want to say that /common/out is FxVS but what can I check to be certain? I'm looking through SAM/Disks & File Systems for /u001 where our /common/out files reside and only see NFS type for /cdrom.
harry d brown jr
Honored Contributor

Re: How to delete massive amount of zero byte files

what do you get when you

cd u001/app/appldevl/appltop/common/out

and then do a

bdf .

or

bdf /u001/app/appldevl/appltop/common/out


What is the logical volume?

live free or die
harry
Live Free or Die
Sandra Nelson_1
Frequent Advisor

Re: How to delete massive amount of zero byte files

root@dbserv1:/u001/app/appldevl/appltop/common/out> bdf .

Filesystem kbytes used avail %used Mounted on /dev/vgora2/lvol1 18432000 17545604 872584 95% /u001
harry d brown jr
Honored Contributor

Re: How to delete massive amount of zero byte files

How stupid of me. The error is because you did this:

find /common/out -type f -size 0c -exec rm -f {} \;


right? If so, then try this:

cd /u001/app/appldevl/appltop/common/out
find . -type f -size 0c -exec rm -f {} \;

or

find /u001/app/appldevl/appltop/common/out -type f -size 0c -exec rm -f {} \;

live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor
Solution

Re: How to delete massive amount of zero byte files

You can do a grep of u001 out of /etc/fstab:

grep u001 /etc/fstab

and the result will tell you the "type" of filesystem. Also for more info on the "filesystem"/"Logical Volume" do this:

lvdisplay -v /dev/vgora2/lvol1 | more


live free or die
harry
Live Free or Die
Sandra Nelson_1
Frequent Advisor

Re: How to delete massive amount of zero byte files

find /u001/app/appldevl/appltop/common/out -type f -size 0c -exec ls -l {} \; shows only the zero byte files in the directory I want to clean up. Yes!

Thank you! Now I feel confident that using the rm -f will ONLY remove those files and no others.

Thank you so very much!
harry d brown jr
Honored Contributor

Re: How to delete massive amount of zero byte files


Happy hunting :-)

live free or die
harry
Live Free or Die