[rhn-users] auto cleanup of /tmp on boot

Sterling, James A james.a.sterling at boeing.com
Thu Aug 31 19:35:27 UTC 2006


And to add to this thread if I may

I have a very simple script that cleans out tmp of files and directories
that are 'older' then a day.

==========================================================
#!/sbin/sh
#
# just to clean out tmp of any files older then one day
#
# simple .. cd to tmp and then do a find with mtime +1 and remove same
cd /tmp
find . -type f -mtime +1 -exec rm {} \;
find . -type d -mtime +1 -exec rm -fr {} \;
==========================================================

It is looking for files or directories that are older then one day and
then removes them
I run this from a adm cron job.. And it seems to work well 

Hope this helps.. 

Jim Sterling

-----Original Message-----
From: Corne Beerse [mailto:cbeerse at gmail.com] 
Sent: Thursday, August 31, 2006 11:04 AM
To: Red Hat Network Users List
Subject: Re: [rhn-users] auto cleanup of /tmp on boot

allen.jordan at convergys.com wrote:

>
>
>Is there something already in place in the OS that will clean up /tmp 
>on a boot?
>Or do I need to add my own script?
>If so, does anyone have a script?
>  
>

For what it is worth: the long-time unix default is to remove all files
from /tmp on boot. Directories in there tend to stay there with their
contents. It is in one of the `rc` files (see /etc/init.d) and it should
be called relative early in the boot process. However, it should not be
passed when booting to single-user mode: thats a location to trace stuff
where the previous contents of /tmp can come in handy.

My opinion is that it should also remove the subdirectories (the entire
tree below /tmp) and one should expect that: Lots of current
implementations have /tmp on a filesystem that is cleared on boot. For
example on a ramdisk or such.

If a tool needs a boot-save temporary storage, use /var/tmp. That is
there for ages too: vi uses it for example.


Regards

CBee

_______________________________________________
rhn-users mailing list
rhn-users at redhat.com
https://www.redhat.com/mailman/listinfo/rhn-users




More information about the rhn-users mailing list