Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you truncate log files ?

Status
Not open for further replies.

dandan123

Technical User
Sep 9, 2005
505
US
How do you truncate log files keeping only the latest info ?

I know you can cat /dev/null > log.file to zero it.
 
Why not copy the current file to a .1 file and zero the original?

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Then decide how big you want your log file to be, divide that number in half, then rotate your log files the way I described. That way your log file will always be between 1/2x - x.

Or you can write a little script to take the head or tail of your file as far as you want into a new file then replace as original.

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top