mail

December 22, 2009participate at 12:58 pm

faq

Initialization or clearing of log files

Initialization or clearing of log files
Hot:sun Initialization or clearing of log filessun dark Initialization or clearing of log filessun dark Initialization or clearing of log filessun dark Initialization or clearing of log filessun dark Initialization or clearing of log files

Like all Unix file systems, open log files can cause a real problem when they get too large and need to be deleted. The problem is, if you delete an open file, the link is removed, but all of the inodes are lost. Even worse, if the program continues to log to the file, the link never re-appears, and additional inodes are lost and are unrecoverable. I suggest two solutions to the above problems.

If you have lost inodes, a simple reboot (make sure FSCK is run on startup) will recover lost inodes and missing filespace.

To empty (or zero out) an open log file, simply issue the following command:

date > logfile

This will 'empty' the file and insert as the first line the output from the date command. If you want a completely empty file, don't enter date,

just > logfile.

This works great on apache and other web server logs, without ever stopping the service.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • blogmarks
  • Blogosphere News
  • co.mments
  • HelloTxt
  • Ping.fm
  • Reddit
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Add to favorites
  • BlinkList
  • Diigo
  • email
  • Identi.ca
  • LinkedIn
  • Live
  • MyShare
  • MySpace
  • PDF
  • SheToldMe
  • Slashdot
  • Socialogs
  • Tumblr

related post

CBA0E3ABEB1A7038A3FD2A47BA03BC1B Initialization or clearing of log files

Technorati Tags: Linux

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Trackback/Ping

  1. Initialization or clearing of log files - Amit Agarwal Zero Me Dec 25 2009 at 10pm:

    [...] posted here: Initialization or clearing of log files – Amit Agarwal By admin | category: zero command | tags: fact, file, from-the-date, issue-the-following, [...]

Leave a reply
privacy

Back to top

feedback podcast