January 31, 2011

"Disk usage 100% ? Retain latest ‘x’ number of entries of a file and delete the rest of the contents"

Filed under: Miscellaneous — SupportPRO Admin @ 5:55 am

Having issues with 100% diskspace in your Linux dedicated server. An easy and quick way is to clear the log files and thereby you can acquire quite a large amount of usable diskspace.
Check the following:
1. Check the total disk usage:
[root@testserver /]# df -h
2. Check the size of a each folder:
[root@testserver /]# du -sch * or du -sch /foldername command

 

3. Suppose if error logs is taking a lot of space, you can always try to clear it. You can keep x number of latest entries for your reference and can null the old entries.
To achieve this, perform the following:
[root@testserver /]#  vi error_log_new // create a new file to save the latest entries
[root@testserver /]#  tail -1000 error_log >  error_log_new // this copies latest 1000 entries from error_log to error_log_new
[root@testserver /]#  > error_log // clear the contents
[root@testserver /]#  mv error_log_new  error_log // move the contents of the latest error_log to the cleared file
overwrite?: yes

AddThis Social Bookmark Button

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress