script for dealing with temporary files

Bruce Raup brauplists at GMAIL.COM
Fri Jun 16 16:51:34 EDT 2006


I see in the mapserver documentation that a suggested way for removing
temporary files that mapserver creates is a simple 'find' command:

#!/bin/csh
find /usr/local/www/docs/tmp -follow -name "*.gif" -exec rm {} \;

A problem with this is that it even removes files that have just been
created.  The -mtime option to find is a bit of help if you can wait a
day to delete files, but we didn't have that option.  So I wrote a
simple script in perl that allows you to specify a minimum age in
minutes a file should have before it gets deleted.  I'm sure many
other people have written such scripts, probably better ones than
mine, but I thought I share mine since it's definitely better than the
above 'find' command.  It's available at
http://cires.colorado.edu/~braup/software/clean_tmp_area.pl

If you have any comments or suggestions for improvement, I'd be happy
to hear about them.

Cheers,
Bruce

-- 
Bruce Raup
http://cires.colorado.edu/~braup/



More information about the mapserver-users mailing list