Using tmpwatch to free resources


Tmpwatch is a service that can recursively remove files that haven’t been accessed for a given period of time. In the case of CentOS it comes standard. If not enabled to run periodically, the tmp folder will expand until either the server is restarted, or it hits its disk resource┬álimit. If the tmp folder does become to large, all programs that rely on temporary files will fail.

Ex: A apache webserver runs a php script which logs information for referencing. These log files are unwritable due to a lack of disk resources.

It will appear to be a permissions read / write error. However, a simple execution of the following tmpwatch command will free up space and delete all files older than 12 hours.

tmpwatch 12 /tmp

Note: Never delete all files in the tmp folder as they may be utilized for semaphore locking by various applications (mysql).

Leave a Reply

Your email address will not be published.