Operating System - HP-UX
1753798 Members
7899 Online
108805 Solutions
New Discussion юеВ

Re: a log file has a so big size ! even large then the filesystem!

 
SOLVED
Go to solution
timber
Occasional Advisor

a log file has a so big size ! even large then the filesystem!

Hi All
bdf show:
Filesystem kbytes used avail %used Mounted on
/dev/vgfile/lvmsg 20480000 4309873 15159596 22% /msg
and in the directory ll show:
total 6905078
-rw-r--r-- 1 msg users 131288693050 May 12 09:15 queue_10.err

Now ,I've known the file is a sparse file for du -sk show the true size about 4G+,and xd show large of "0" from head of the file.

What I want to know is:
1.How can i reduce the file,or make the ll's show as nomal
2.The admin have clear the file by #>quwue_10.err. Is this a right way?
May Force be with you !
13 REPLIES 13
Robert-Jan Goossens
Honored Contributor

Re: a log file has a so big size ! even large then the filesystem!

Hi Timber,

If you do not need the to keep a copy of the data, you can zeroing the file;

# > /full_path_to_file/queue_10.err
or
# cp /dev/null /full_path_to_file/queue_10.err

Regards,
Robert-Jan
avizen9
Esteemed Contributor

Re: a log file has a so big size ! even large then the filesystem!

hi,

#>quwue_10.err. Is this a right way?

this will balnk whole file and remain same attribute, if you feel this file doesnt require can do this, yes this is correct way, thanks,
Ganesan R
Honored Contributor

Re: a log file has a so big size ! even large then the filesystem!

Hi,

You can use this as well.

#cat /dev/null > /path of the the file
Best wishes,

Ganesh.
timber
Occasional Advisor

Re: a log file has a so big size ! even large then the filesystem!

Additional:
My doubt:the admin use > clear a 5G file but when app reopen the file ,the size increase begin from 5G!So a 5G true size file maybe show us 10G by ls -l.and so on
the file will bigger and bigger....
Is this possble?
May Force be with you !
Suraj K Sankari
Honored Contributor

Re: a log file has a so big size ! even large then the filesystem!

Hi,

The correct way of trimming any type of log file is
# > filename
It will trim your file to 0 (zero) bytes.

Suraj
Michal Kapalka (mikap)
Honored Contributor

Re: a log file has a so big size ! even large then the filesystem!

hi,

no because when the file will be reopen the size will be zero.

mikap
Ganesan R
Honored Contributor

Re: a log file has a so big size ! even large then the filesystem!

Hi,

In that case terminate the process which uses the space using lsof then restart the process.

The space will be released by the process only after it terminates.
Best wishes,

Ganesh.
Jozef_Novak
Respected Contributor

Re: a log file has a so big size ! even large then the filesystem!

Hello,

use the trimming by "> filename" only if it contains plain text. Doing this to a binary file (for example /var/adm/wtmp) can corrupt the file so that it will no more be readable by the process that uses it.

J.
timber
Occasional Advisor

Re: a log file has a so big size ! even large then the filesystem!

Unfortunately,after i user "msg" account do the >file clear,but size of file still shown 130G+
May Force be with you !