In a Linux System, services like Apache, mysql write temporary files to /tmp partition. If /tmp partition is full then there is a high chance of service could crash.

To overcome this situation, we are going to use tmpwatch utility to clear the /tmp partition.

Let’s install tmpwatch utility. If its centos, we can install tmpwatch using yum utility.

yum -y install tmpwatch

To clear the tmp partition, execute the below mentioned command.

tmpwatch –all -mtime 24 /tmp

The above command will delete the files which are older than 24 hours.

To perform this task periodically,  let’s add it in crontab

@daily * * * *  /usr/sbin/tmpwatch –all –mtime 24 /tmp

 

 

Leave a Reply