Disk usage 100% ? Retain latest entries of a file and delete the rest of the contents
Have 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