[Mapserver-users] Deleting old GIF image files
Antti.Roppola at brs.gov.au
Antti.Roppola at brs.gov.au
Tue Jun 24 01:20:09 PDT 2003
My example is a non-Mapserver app and calls a shell script from
inside the app's home page, but it's not hard to do something similar
entirely in PHP for Mapserver. Say insert something like this in a page
visited reasonably frequently by users:
<?php
foreach (glob("./path/to/tmp/mapserv/*.gif") as $filename) {
if( (time() - filectime($filename)) > 3600 ) { // if it's more than an hour old
unlink($filename); // delete it
}
}
?>
Of course you can use all sorts of criteria besides date, you could
always use OS calls from the page to run a script something like:
$num =`ls -t /tmp/*.gif | wc -l`
$num = $num - 10
$success=`ls -t /tmp/*.gif | head -$num | xargs rm`
But that's just getting ugly for no good reason (and won't work on Windows anyway).
BTW, I have just typed these into my email and not tried them out.
I strongly recommend testing them before deleting your vital system files.
Cheers,
Antti
-----Original Message-----
From: W. Steph [mailto:chewbizz at hotmail.com]
Sent: Tuesday, 24 June 2003 5:58 PM
To: Antti.Roppola at brs.gov.au
Subject: RE: [Mapserver-users] Deleting old GIF image files
Yes, that's a good idea !
Could you post your "few lines" to the list, I think many users of php
MapScript would like to use this code
Thank you
Steph
>From: Antti.Roppola at brs.gov.au
>To: Mapserver-users at lists.gis.umn.edu
>Subject: RE: [Mapserver-users] Deleting old GIF image files
>Date: Tue, 24 Jun 2003 10:36:18 +1000
>
>Or if you want something more demand driven, I added a few lines
>to the PHP to delete all but the 10 most recent images.
>
>Unlike a cron job, this will automagically clean up the directory
>more often if required.
>
>Antti
>
>-----Original Message-----
>From: Krzysztof Chodak [mailto:k.chodak at autoguard.pl]
>Sent: Monday, 23 June 2003 6:50 PM
>To: MAPSERVER
>Subject: Fw: [Mapserver-users] Deleting old GIF image files
>
>
>I personally use wsh script (Windows):
>
> <job>
> <script language="JSCript">
> var fso = WScript.CreateObject("Scripting.FileSystemObject"),
> startDate = new Date(),
> folder = fso.GetFolder("D:\\tmp\\"),
> files = new Enumerator(folder.Files),
> file
> while (!files.atEnd())
> {
> file = files.item()
> if ((startDate - new Date(file.DateLastModified)) > 86400000)
> {
> file.Delete()
> }
> files.moveNext()
> }
> </script>
> </job>
>
> it is saved in CleanUpTemp.wsf file. I use Task Scheduling to run it from
> time to time (currently once per day). Script is launched by following
> command:
> C:\WINNT\system32\cscript.exe CleanUpTemp.wsf
>
> BR
>
>Krzysztof Chodak
>
> >
> > ----- Original Message -----
> > From: Thomas Jensen
> > To: mapserver-users at lists.gis.umn.edu
> > Sent: Monday, June 23, 2003 8:58 AM
> > Subject: [Mapserver-users] Deleting old GIF image files
> >
> >
> > Hi
> >
> > I would like to know if anyone can suggest a sollution to my problem. I
>have
> > used MapServer to generate mapImages on the www.langelandatlas.dk
>website.
> > The problem is, that the ms_temp folder which contains the GIF image
>files
> > rapidly is filled with old image files which are no longer used. Can
> > MapServer be set ud to automatically delete the image files it has
>created
> > after they have been used?
> >
> > Sincerely
> >
> > Thomas Jensen
> > Sven Allan Jensen as
> > Sankelmarksgade 9
> > DK - 9000 Aalborg
> > Ph: 96 31 40 64
> > E-mail: tj at svaj.dk
> > www.svaj.dk
> >
>
>_______________________________________________
>Mapserver-users mailing list
>Mapserver-users at lists.gis.umn.edu
>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
>_______________________________________________
>Mapserver-users mailing list
>Mapserver-users at lists.gis.umn.edu
>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
_________________________________________________________________
Le nouveau MSN Messenger est arrivé : http://g.msn.fr/FR1001/866 essayez-le
aujourd'hui !
More information about the MapServer-users
mailing list