My scrapbook about anything which I learned or want to remember, Sometime about tech tips, thoughts and rambling. If you find anything useful don't forget to give thumbs-up :)

Breaking

Thursday, September 17, 2020

Clean your /var directory in RHEL Linux (CentOS/Fedora/Redhat)

While working on one of the Jenkins job, an error popped up - JENKINS_HOME is almost full. This worries me as my root '/' have 60% of total storage whatever I have in distro (CentOS 8.2). So started digging in and found out the culprit. Let's see how you can also do the same. 


Step 1: Let's first search which directory is consuming your space by running below command. 

$ du -sch /* 2> /dev/null    # image-1

root

Step 2: As we can see in left image, /var directory is consuming more space than any other directory, we will repeat the same process for /var directory now, or for any other directory as well. 

$ du -sch /var/* 2> /dev/null   # image-2
$ du -sch /var/crash/* 2> /dev/null  # image-3

var var_crash

As you can see, there is huge files under  /var/crash folder which is nothing but are backups whenever you have updated your OS distro, You can carefully remove these files to recover the storage. 
    You can also truncate huge log files, sometimes log files are huge to help in restoration. and by carefully means, avoid any latest backup files removal or truncation of any binary files. You can follow below commands to truncate your log files or may be put round robin logging mechanism on software or OS.


Truncate files:

$ tail -5000 filename > filename.new
$ mv filename.new filename
$ sync

We can follow the same procedure for other folders as well but don't delete anything which you don't understand cause Linux systems are so complicated as well as so simple at the same time. A wise person said, "Dont jump off the cliff if you don't know how to fly." 

Hoping, this post will help you..I'll see you in next post.. till then.. Happy Learning !!! 



Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group


No comments:

Post a Comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.