<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">


<META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2>The problem there is that you cronjob is likely to delete 
files as they're about to being used ... It's a fraction of a second, but it can 
happen (In fact, it did for me).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2>The end result is that some very unlucky users get "broken" 
maps for no obvious reasons (because the cronjob ran at that point in time 
between the rendering of the map, and the browser fetching 
it).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2>This is why letting the image sit around for a few minutes 
is recommended.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2>Also, you can gain some performance from keeping the legend 
symbology around ... as they're relatively expensive, since there can be lots of 
very small images, and the HTTP over head is marginally significant.&nbsp; If 
you keep them around, not only does mapserver not render them unnecessarily, but 
also, the browsers cache them.&nbsp; It makes a noticeable difference for us 
anyways, with sometimes large HTML legends with lots of 
symbols.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=339474213-19062006><FONT face=Arial 
color=#0000ff size=2>J.F.</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> UMN MapServer Users List 
[mailto:MAPSERVER-USERS@LISTS.UMN.EDU] <B>On Behalf Of </B>M S<BR><B>Sent:</B> 
June 16, 2006 6:42 PM<BR><B>To:</B> 
MAPSERVER-USERS@LISTS.UMN.EDU<BR><B>Subject:</B> Re: [UMN_MAPSERVER-USERS] 
script for dealing with temporary files<BR></FONT><BR></DIV>
<DIV></DIV>how about a cron job: <BR>0 1 * * * /path/to/script<BR><BR>that runs 
a shell script:<BR>rm -f /path/to/tmp/files/*;<BR><BR><BR>
<DIV><SPAN class=gmail_quote>On 6/16/06, <B class=gmail_sendername>Doyon, 
Jean-Francois</B> &lt;<A onclick="return top.js.OpenExtLink(window,event,this)" 
href="mailto:Jean-Francois.Doyon@ccrs.nrcan.gc.ca" target=_blank> 
Jean-Francois.Doyon@ccrs.nrcan.gc.ca</A>&gt; wrote:</SPAN> 
<BLOCKQUOTE class=gmail_quote 
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Good 
  idea.<BR><BR>Here's mine, written in Python.&nbsp;&nbsp;It preserves the 
  legend symbology but<BR>deletes other temporary images generated by 
  mapserver:<BR><BR>#!/home/atlas/web/bin/python<BR><BR># Directory where 
  MapServer temporary files are created<BR><BR>TMPDIR = 
  '/dev/shm/atlas'<BR><BR># Time-To-Live (TTL) in minutes <BR><BR>TTL = 
  5<BR><BR># Nothing to change below<BR><BR>from glob import glob<BR>from 
  os.path import getatime<BR>from os import unlink<BR>from time import 
  time<BR>import re<BR><BR>filelist = glob(TMPDIR + '/*.gif') + glob(TMPDIR + 
  '/*.img.tmp') <BR>grace = TTL * 60<BR><BR>for file in 
  filelist:<BR>&nbsp;&nbsp;&nbsp;&nbsp;try:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;atime 
  = getatime(file)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if atime 
  &lt; time() - grace and 
  not<BR>re.match('^.*?_\d{5,6}_\d{10}_\d{1,2}_\d{1,2}_\d{1,2}_\d{1,2}\.gif$', 
  file): 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unlink(file)<BR>&nbsp;&nbsp;&nbsp;&nbsp;except:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass<BR><BR>Cheers,<BR>J.F.<BR><BR>-----Original 
  Message-----<BR>From: UMN MapServer Users List [mailto:<A 
  onclick="return top.js.OpenExtLink(window,event,this)" 
  href="mailto:MAPSERVER-USERS@LISTS.UMN.EDU" target=_blank> 
  MAPSERVER-USERS@LISTS.UMN.EDU </A>] On<BR>Behalf Of Bruce Raup<BR>Sent: June 
  16, 2006 4:52 PM<BR>To: <A 
  onclick="return top.js.OpenExtLink(window,event,this)" 
  href="mailto:MAPSERVER-USERS@LISTS.UMN.EDU" 
  target=_blank>MAPSERVER-USERS@LISTS.UMN.EDU</A> <BR>Subject: 
  [UMN_MAPSERVER-USERS] script for dealing with temporary files <BR><BR>I see in 
  the mapserver documentation that a suggested way for removing<BR>temporary 
  files that mapserver creates is a simple 'find' 
  command:<BR><BR>#!/bin/csh<BR>find /usr/local/www/docs/tmp -follow -name 
  "*.gif" -exec rm {} \; <BR><BR>A problem with this is that it even removes 
  files that have just been<BR>created.&nbsp;&nbsp;The -mtime option to find is 
  a bit of help if you can wait a day<BR>to delete files, but we didn't have 
  that option.&nbsp;&nbsp;So I wrote a simple script <BR>in perl that allows you 
  to specify a minimum age in minutes a file should<BR>have before it gets 
  deleted.&nbsp;&nbsp;I'm sure many other people have written such<BR>scripts, 
  probably better ones than mine, but I thought I share mine since <BR>it's 
  definitely better than the above 'find' command.&nbsp;&nbsp;It's available 
  at<BR><A onclick="return top.js.OpenExtLink(window,event,this)" 
  href="http://cires.colorado.edu/%7Ebraup/software/clean_tmp_area.pl" 
  target=_blank>http://cires.colorado.edu/~braup/software/clean_tmp_area.pl</A><BR><BR>If 
  you have any comments or suggestions for improvement, I'd be happy to<BR>hear 
  about them.<BR><BR>Cheers,<BR>Bruce<BR><BR>--<BR>Bruce Raup<BR><A 
  onclick="return top.js.OpenExtLink(window,event,this)" 
  href="http://cires.colorado.edu/%7Ebraup/" 
  target=_blank>http://cires.colorado.edu/~braup/ 
</A><BR></BLOCKQUOTE></DIV><BR></BODY></HTML>