{"id":406,"date":"2011-01-31T05:55:19","date_gmt":"2011-01-31T11:55:19","guid":{"rendered":"http:\/\/blog.supportpro.com\/2011\/01\/disk-usage-100-retain-latest-x-number-of-entries-of-a-file-and-delete-the-rest-of-the-contents\/"},"modified":"2025-04-28T05:10:39","modified_gmt":"2025-04-28T11:10:39","slug":"disk-usage-100-retain-latest-x-number-of-entries-of-a-file-and-delete-the-rest-of-the-contents","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/disk-usage-100-retain-latest-x-number-of-entries-of-a-file-and-delete-the-rest-of-the-contents\/","title":{"rendered":"Disk usage 100% ? Retain latest entries of a file and delete the rest of the contents"},"content":{"rendered":"<p>Have issues with 100% diskspace in your Linux dedicated server. An easy and quick way is to <a href=\"https:\/\/www.supportpro.com\/blog\/forcefully-refreshing-disk-space-usage-directly-from-cpanel\/\">clear the log files<\/a> and thereby you can acquire quite a large amount of usable diskspace.<br \/>\nCheck the following:<br \/>\n1. Check the total disk usage:<br \/>\n[root@testserver \/]# df -h<br \/>\n2. Check the size of a each folder:<br \/>\n[root@testserver \/]# du -sch * or du -sch \/foldername command<\/p>\n<p><!--more--><\/p>\n<p>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.<br \/>\nTo achieve this, perform the following:<br \/>\n[root@testserver \/]#\u00a0 vi error_log_new \/\/ create a new file to save the latest entries<br \/>\n[root@testserver \/]#\u00a0 tail -1000 error_log &gt;\u00a0 error_log_new \/\/ this copies latest 1000 entries from error_log to error_log_new<br \/>\n[root@testserver \/]#\u00a0 &gt; error_log \/\/ clear the contents<br \/>\n[root@testserver \/]#\u00a0 mv error_log_new\u00a0 error_log \/\/ move the contents of the latest error_log to the cleared file<br \/>\noverwrite?: yes<\/p>\n<p>If you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><\/p>\n<p style=\"text-align: center;\"><!--HubSpot Call-to-Action Code --><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><!-- [if lte IE 8]><\/p>\n\n\n\n\n\n<div id=\"hs-cta-ie-element\"><\/div>\n\n\n<![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b\"><img decoding=\"async\" id=\"hs-cta-img-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-img\" style=\"border-width: 0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b.png\" alt=\"Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value\" \/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '9d590242-d641-4383-94b4-8cfd62f0af6b', {}); <\/script><\/span><!-- end HubSpot Call-to-Action Code --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1,7],"tags":[],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-miscellaneous","category-server-tweaking"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":3,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":14571,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/406\/revisions\/14571"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}