clean out /tmp?

Jeff Vian jvian10 at charter.net
Mon Sep 26 22:49:02 UTC 2005


On Tue, 2005-09-27 at 09:48 +1200, Morgan Read wrote:
> Hi,
> Is there a way to keeping my /tmp's cleaned out in FC?
> 
> I had what I thought was the perfect answer to keeping my /tmp's trim and in
> shape by using cron scripts - but, it appears to apply to suse only?  (See
> bellow.)
> 

See my notes below.  It is automatic and built-in.

> Regards,
> Morgan.
> 
> -------- Original Message --------
> Subject: Re: [nzlug] clean out /tmp?
> Date: Mon, 26 Sep 2005 09:53:21 +1200
> From: Volker Kuhlmann <hidden at paradise.net.nz>
> Reply-To: NZLUG Mailing List <nzlug at linux.net.nz>
> To: NZLUG Mailing List <nzlug at linux.net.nz>
> References: <43313D6F.2010803 at pl.net>
> <a96bb250050921042435a1a7fb at mail.gmail.com>
> <1127330910.5889.1.camel at localhost>	<20050921205731.GA672 at paradise.net.nz>
> <433684DF.1050800 at pl.net>
> 
> > I got to having a look at this cron file and I have no /etc/sysconfig/cron.
> > I'm running FC4, is it likely to have a different set-up?
> 
> Looks like it, yes. I use SuSE.
> 
> > Other things that may be relevant:
> > - /etc/cron.d/ (empty)
> > - /etc/cron.hourly/ -> ... /cron.monthly/
> > - /etc/crontab
> 
> This is the mechanism to control a standard unix cron daemon. In turn,
> the scripts in these directories (and in /etc/init.d/) read
> /etc/sysconfig/cron and act on it.
> 
/etc/crontab is the global crontab file.  In FC the users crontab files
are located in /var/spool/cron.

Periodic crontab scripts that are run regularly (hourly, daily, weekly,
monthly, etc. are in the appropriate /etc/cron.XXXX directories.
In /etc/cron.daily I see the script tmpwatch (/etc/cron.daily/tmpwatch)
which seems to me to do what you are asking and more.  I never see any
old files existing except the ones that are excluded in that script.

FC has a default procedure for keeping /tmp cleared.  If you need
something more specific, you could either write your own script or
modify the default and it will work for you.


> > - /etc/sysconfig/crond (which doesn't contain the text)
> 
> This looks like it's the equivalent file for FC. If you can't find any
> commments in this file relating to clearing temp directories, than I'd
> conclude that FC isn't as sophisticated in this department.
> 

This file (/etc/sysconfig/crond) is used to configure crond at startup
only.  It is not the same as in Suse.

> > If your /etc/sysconfig/cron isn't personal, can you copy it across (and
> > would it work)?
> 
> The file is not personal, you can find it in the package
> ftp://ftp.opensuse.org/pub/opensuse/distribution/SL-10.0-OSS-RC1/inst-source/suse/i586/aaa_base-10.0-27.i586.rpm
> at /var/adm/fillup-templates/sysconfig.cron. No it would not work unless
> you also installed the (parts of) the scripts which read this file.
> These are
> /etc/init.d/boot.cleanup
> /etc/cron.daily/suse.de-clean-tmp
> in the same package. You're on your own surgically implanting the
> correct parts into FC.

> >> The easiest would seem to be to edit /etc/sysconfig/cron and the system
> >> will do the rest. The guts of that are below.

see above.

> >> 
> >> Volker
> >> 
> >> 
> >> # cron.daily can check for old files in tmp-dirs. It will delete all files
> >> # not accessed for more than MAX_DAYS_IN_TMP. If MAX_DAYS_IN_TMP is not set
> >> # or set to 0, this feature will be disabled. 
> >> #
> >> MAX_DAYS_IN_TMP="7"
> >> 
> >> ## Type:	string
> >> ## Default:	"/tmp"
> >> #
> >> # This variable contains a list of directories, in which old files are to
> >> # be searched and deleted. The frequency is determined by MAX_DAYS_IN_TMP
> >> #
> >> TMP_DIRS_TO_CLEAR="/tmp /var/tmp"
> >> 
> >> # "Set this to "yes" to entirely remove (rm -rf) all  files and subdirectories
> >> # from the temporary directories defined in TMP_DIRS_TO_CLEAR on bootup.
> >> # Please note, that this feature ignores OWNER_TO_KEEP_IN_TMP - all files will
> >> # be removed without exception."
> >> #
> >> # If this is set to a list of directories (i.e. starts with a "/"), these
> >> # directories will be cleared instead of those listed in TMP_DIRS_TO_CLEAR.
> >> # This can be used to clear directories at boot as well as clearing unused
> >> # files out of other directories.
> >> #
> >> CLEAR_TMP_DIRS_AT_BOOTUP="/tmp"
> 
> HTH,
> 
> Volker




More information about the fedora-list mailing list