Operating System - HP-UX
1748142 Members
3561 Online
108758 Solutions
New Discussion юеВ

Re: compressing all the small files

 
SOLVED
Go to solution
gany59
Regular Advisor

compressing all the small files

Hi techiees,

/tmp getting full due to many small files, so is there any way to compress all the files into one archive and then again compress by gzip

Could any body help me out on this...
Thanks in advance
10 REPLIES 10
smatador
Honored Contributor
Solution

Re: compressing all the small files

Hi,
I don't have a system to test but I think
You could try something start by
find /tmp -size < size of small files >| tar cvf backup_smallfile.tar
or
find /tmp -size < size of small files >| xargs tar cvf backup_smallfile.tar | gzip -c > backup.tar.gz
HTH
Michael Steele_2
Honored Contributor

Re: compressing all the small files

Hi

Yep, that's how I'd do it.
Support Fatherhood - Stop Family Law
James R. Ferguson
Acclaimed Contributor

Re: compressing all the small files

Hi:

The '/tmp' filesystem is intended for use by the operating system. Generally, the files placed within are small lock files and socket files. '/var/tmp' is the proper repository for application temporary files.

How many is "many"? How "small" is small? How old are the files and what are they?

You can configure your server to remove the contents of the '/tmp' directory at startup. It sounds like you need to do some cleanup.

Regards!

...JRF...
gany59
Regular Advisor

Re: compressing all the small files

Many files in the size 1200128 are generated before a month and many zero size files are generated before a week..

i just really confused how to compress all these files into one archive
gany59
Regular Advisor

Re: compressing all the small files

If i tried the below commands , it will show the error like
find /tmp -size 1024 | tar cvf backup_smallfile.tar
Attempt to create archive of no files. Nothing dumped.

please let me know on this


Jean-Luc Oudart
Honored Contributor

Re: compressing all the small files

I think you need to change the find command :

find /tmp -type f -size -1024c |

(for file smaller than 1024 char)

Regards
Jean-Luc
fiat lux
gany59
Regular Advisor

Re: compressing all the small files

Hi
while i am trying this command also ,, it shows the error

find /tmp -type f -size -1024c | tar cvf backup_smallfile.tar
Attempt to create archive of no files. Nothing dumped.
Jean-Luc Oudart
Honored Contributor

Re: compressing all the small files

try
find /tmp -type f -size -1024c | xargs tar cvf backup_smallfile.tar

Regards
Jean-Luc
fiat lux
Dennis Handly
Acclaimed Contributor

Re: compressing all the small files

As JRF mentioned, you should just remove these files, possibly based on age.

>Attempt to create archive of no files. Nothing dumped.

As I say below, you can't use HP-UX's tar.

>smatador: find /tmp -size | tar cvf backup_smallfile.tar

You are not going to be able to use tar with find. The correct tools are pax(1), cpio(1) or GNU tar.
find /tmp -size -10000 | pax -w | gzip > backup.tar.gz

>Jean-Luc: find /tmp -type f -size -1024c | xargs tar cvf backup_smallfile.tar

Again, you need to give up on tar.