How to clean your tmp folder with tmpwatch to fix mysql issue.

How to clean your tmp folder with tmpwatch to fix mysql issue.
5/5 - (6 votes)

Introduction

Some Server has a MySQL issue because /tmp becomes full regularly. When tmp directory is full it creates issue MySQL socket issue in cpanel, and this issue can be fixed by clean your tmp folder/tmp. In this guide, we will use a third-party program for clearing the /tmp directory called tmpwatch. This article will show you how to clean tmp data with tmpwatch and how to install tmpwatch and set up a cron job so that it can clean the /tmp directory of old files on a regular basis. 

Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

This tutorial is also use to fix the issue of mysql.sock can’t connect.

Steps

1. You Need to Install tmpwatch. simply run this yum install tmpwatch command to install the tmpwatch, it will tell you there is nothing to do and no harm will be caused.

yum install tmpwatch

2. Run tmpwatch to clear the /tmp partition of files over a week old now:

tmpwatch --mtime --all 168 /tmp

Check to see if some files were actually removed from /tmp.  If not, decrease the number of hours (in this case 168) until enough files are removed to give sufficient space in /tmp.  Do not lower the number below 12. 

3. Add tmpwatch to root’s crontab to clear old files (more than a week old) every night.  If you needed to lower the number of hours in step 2, lower it here as well. 

0 0 * * * tmpwatch --mtime --all 168 /tmp
Total
0
Shares
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Previous Post
Fix cPanel Installation issue (FATAL): Unable to create /etc/selinux/config. in this tutorial you will learn how to fix file permission error, Cpanel installation issue, centos SELinux issue.

(FATAL): Unable to create /etc/selinux/config

Next Post
Check Linux Uptime With Simple Commands

Check Linux Uptime With Simple Commands

Related Posts
Total
0
Share
0
Would love your thoughts, please comment.x
()
x