System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to empy the large size file?

SOLVED
Go to solution
mrk_1
Frequent Advisor

How to empy the large size file?

Hi All,
I need to remove some of the log file for informix db. Instead of removing I thought to empty the file.

Can any one tell me whata is the command to empty the file.

Thanks in advance.
10 REPLIES
James R. Ferguson
Acclaimed Contributor
Solution

Re: How to empy the large size file?

Hi:

To truncate a file (reduce it to 0-characters), simply do:

# cat /dev/null > file

(or more succinctly):

# > file

Regards!

...JRF...
Md. Farhan A Azam
Trusted Contributor

Re: How to empy the large size file?

Hi you can purge the file

#> {filename},

prior excuting the command, ensure that it will hamper your system or not.
Md. Farhan A Azam
Trusted Contributor

Re: How to empy the large size file?

Don't forgot to assign points to whom, who has given you some light on your question.
mrk_1
Frequent Advisor

Re: How to empy the large size file?

Thanks for the help.
Taifur
Respected Contributor

Re: How to empy the large size file?


Do you have dd on your system ?
dd if=/dev/zero of=output.file bs=1024 count=1024

if it helps you, then pls assign point

rgds
Taifur
James R. Ferguson
Acclaimed Contributor

Re: How to empy the large size file?

Hi:

> Taifur: dd if=/dev/zero of=output.file bs=1024 count=1024

This is the hard-way and needless consumes time.

Doing '> file' in a shell immediately truncates the end-of-file pointer to the beginning, nulling or emptying the file.

Regards!

...JRF...

James R. Ferguson
Acclaimed Contributor

Re: How to empy the large size file?

Hi (again):

> Taifur: dd if=/dev/zero of=output.file bs=1024 count=1024

This is the hard-way and needless consumes time. AND I meant to add that unless you limit the record 'count' you will create an "infinitely" large file that will fill your filesystem. WIth a record count, all you do is overwrite the beginning characters anyway --- not very useful.

[ NO POINTS FOR THIS PLEASE ]

...JRF...

mrk_1
Frequent Advisor

Re: How to empy the large size file?

Thanks a lot for all. I used following command > file to empty the file.

rick jones
Honored Contributor

Re: How to empy the large size file?

It might be good to see if there is a way to trim the log file from within Informix - Informix may indeed not care if you zap the log file whith shell redirection, but it might be best to double check that...
there is no rest for the wicked yet the virtuous have no pillows
rmueller58
Valued Contributor

Re: How to empy the large size file?

Depends on which Informix Log. if it is the standard message log yes you can cat it to /dev/null..

But if it is a transaction log for the db such as if you are doing Online Archives or transaction tracking there are other methods of rotation.