Clean up script for tmp files

Jethro R Binks jethro.binks at strath.ac.uk
Sat Feb 15 12:17:30 GMT 2014


My script was written for FreeBSD.  If you're using a different operating system, you'll need to read the manual page for your 'find' command and modify it accordingly.

> On 15 Feb 2014, at 09:08, Remco Barendse <mailscanner at barendse.to> wrote:
> 
> I slightly modified the script, if i remove "-maxdepth 1"  from opts the 
> script completes without errors and i included /tmp.
> However, the find command doesn't find the files. Even when i set days to 
> 1, i still find files that are 3-4 days old.
> 
> When i do :
>   find /var/spool/MailScanner/incoming/SpamAssassin-Temp/ -name 'tmp.*' 
> it finds all the files, when i add "-mtime +1" it doesn't find anything 
> anymore.
> 
> Clues anyone?  Could it be that mtime doesn't work on zero byte files?
> 
> Thanks!
> 
> 
> 
>> On Wed, 12 Feb 2014, Jethro R Binks wrote:
>> 
>> I've run this nightly for years which may help:
>> 
>> 
>> #!/bin/sh
>> ##
>> ## MailScanner, SpamAssassin and so on tend to leave files around, so this
>> ## will clean up any more than $days old
>> ##
>> ## v2.1
>> 
>> # Defined in MailScanner.conf, "Incoming Work Dir":
>> MSWORK=/mail/scanner/incoming
>> # Defined in MailScanner.conf, "SpamAssassin Temporary Dir":
>> #SATMP=/tmp
>> SATMP=$MSWORK/SpamAssassin-Temp
>> # Defined in clamd.conf, "TemporaryDirectory":
>> CLAMAVTMP=/var/tmp
>> 
>> days="2"
>> 
>> opts="-mtime +$days -maxdepth 1"
>> 
>> find $SATMP -name '.spamassassin*' $opts | xargs rm -rf
>> find $SATMP -name 'update_spamassassin*' $opts | xargs rm -rf
>> find $MSWORK -name '[0-9]*' -type d $opts | xargs rm -rf
>> find $CLAMAVTMP -name 'packlist.*' -type f $opts | xargs rm -rf
>> find $CLAMAVTMP -name 'checkholddir.*' -type f $opts | xargs rm -rf
>> find $CLAMAVTMP -name 'clamav-*' $opts | xargs rm -rf
>> 
>> 
>> 
>> 
>>> On Wed, 12 Feb 2014, Remco Barendse wrote:
>>> 
>>> I know the subject was discussed on the mailing list several times but i
>>> didn't find the ultimate solution.
>>> 
>>> Does anyone have a super duper cleanup script for all the files in :
>>> 
>>> /tmp
>>> for files like  tmp.DPhoj31724
>>> 
>>> /var/spool/MailScanner/incoming/SpamAssassin-Temp
>>> for files like  .spamassassin3805xUDKuUtmp
>>>                 MailScanner.0aOrDx
>>>                 tmp.IKiiOy6683
>>> 
>>> They are seriously clogging up my filesystem and slowing down the system.
>>> 
>>> I tried to script something based on the age of the file but it didn't
>>> work (maybe because most are zero byte files).
>>> 
>>> Thanks!
>>> 
>>> Remco
>>> --
>>> MailScanner mailing list
>>> mailscanner at lists.mailscanner.info
>>> http://lists.mailscanner.info/mailman/listinfo/mailscanner
>>> 
>>> Before posting, read http://wiki.mailscanner.info/posting
>>> 
>>> Support MailScanner development - buy the book off the website!
>>> 
>> 
>> .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
>> Jethro R Binks, Network Manager,
>> Information Services Directorate, University Of Strathclyde, Glasgow, UK
>> 
>> The University of Strathclyde is a charitable body, registered in
>> Scotland, number SC015263.
>> 
> -- 
> MailScanner mailing list
> mailscanner at lists.mailscanner.info
> http://lists.mailscanner.info/mailman/listinfo/mailscanner
> 
> Before posting, read http://wiki.mailscanner.info/posting
> 
> Support MailScanner development - buy the book off the website! 


More information about the MailScanner mailing list