0 1 * * * /path/to/script
that runs a shell script:
rm -f /path/to/tmp/files/*;
On 6/16/06, Doyon, Jean-Francois <
[EMAIL PROTECTED]> wrote:
Good idea.
Here's mine, written in Python. It preserves the legend symbology but
deletes other temporary images generated by mapserver:
#!/home/atlas/web/bin/python
# Directory where MapServer temporary files are created
TMPDIR = '/dev/shm/atlas'
# Time-To-Live (TTL) in minutes
TTL = 5
# Nothing to change below
from glob import glob
from os.path import getatime
from os import unlink
from time import time
import re
filelist = glob(TMPDIR + '/*.gif') + glob(TMPDIR + '/*.img.tmp')
grace = TTL * 60
for file in filelist:
try:
atime = getatime(file)
if atime < time() - grace and not
re.match('^.*?_\d{5,6}_\d{10}_\d{1,2}_\d{1,2}_\d{1,2}_\d{1,2}\.gif$', file):
unlink(file)
except:
pass
Cheers,
J.F.
-----Original Message-----
From: UMN MapServer Users List [mailto: [email protected] ] On
Behalf Of Bruce Raup
Sent: June 16, 2006 4:52 PM
To: [email protected]
Subject: [UMN_MAPSERVER-USERS] script for dealing with temporary files
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/
