cleaning /tmp directory

Wolfgang S. Rupprecht wolfgang.rupprecht at gmail.com
Wed Mar 31 20:21:37 UTC 2010


Gregory Hosler <ghosler at redhat.com> writes:
> On 03/31/2010 09:52 PM, Maurizio Marini wrote:
>> Hi there
>> i need a cron script that cleans every day crap into /tmp
>> I have there a lot of temp files but i dunno which ones can be safely wiped, 
>> and it is very time comsuming job, too.
>> Any script written by someone of you will be very apreciated :)
>> tia
>> Maurizio
>
> There already is a cron that will delete file out of /tmp that are 10 days old.

In addition, at shutdown time everything in /tmp is fair game for
deletion.  As one of the last things done on all my machines I clean out
/tmp.  In my case the reason isn't space, but clutter.  With the default
/tmp cleaning, things build up to such a level that downloaded files
that I only want to look at once are hard to find (such as pdf files
etc).

Put this in /sbin/halt.local mode 755.

#!/bin/sh
###############################################################################
##									     ##
##	File:     halt.local						     ##
##	Author:   Wolfgang S. Rupprecht <wolfgang at wsrcc.com>		     ##
##	Created:  Thu Jun  7 23:47:14 PDT 2007				     ##
##	Contents: wsrcc site-specific halt stuff                             ##
##									     ##
##	Copyright (c) 2007 Wolfgang S. Rupprecht.			     ##
##	All rights reserved.						     ##
##									     ##
##	$Id$								     ##
###############################################################################
# wsrcc halt script

echo "WSRCC: Clearing /tmp"

cd /
/bin/rm -rf /tmp/* /tmp/.??*
sync; sync; sync;

#
# end
#



-- 
Wolfgang S. Rupprecht
If the airwaves belong to the public why does the public only get 3
non-overlapping WIFI channels?


More information about the users mailing list