linux

Cleaning up the tmp disk on Linux

I’d been ignoring emails from one of the web servers that I look after for months. They were telling me that the tmp disk was critically full at 94%, I fobbed it off as not being ‘critical’ as it still had 6% left – head buried in sand. Anyway, today I decided to fix it as I had a bit of free time during the day.

I Googled how to increase the size of the tmp disk, but this looked rather complicated so I was scared off. So my next Google was to find out how to clean out the tmp disk and I found this article which was very useful and showed me how to clean out all the stuff over 12 hours old, and then add that command to the cron job so it didn’t automatically every day.

  • Basically you have to install something called ‘tmpwatch’: yum install tmpwatch -y
  • Then when this is installed, you run the cleaning command with this: /usr/sbin/tmpwatch -am 12 /tmp
  • This cleans up everything over 12 hours old. Which is nice.
  • You then want to set it so it does it automatically for you so go into your cronjob file with this: crontab -e
  • Then add the command that we ran earlier to the bottom of this file like so: 0 4 * * * /usr/sbin/tmpwatch -am 12 /tmp

My tmp disk went from a critical 94% full to a nicer looking 30%. No idea what that will do to the server, but at least I won’t get any more emails for a while!

Leave a Reply

Your email address will not be published. Required fields are marked *