.. index::
   single: File management

.. _management:

*****************************************************************************
 File Management
*****************************************************************************

.. index::
   single: File placement

.. index::
   single: File paths

File Placement
--------------

MapServer requires a number of different files to execute. Except for graphics 
that are referenced in output templates (i.e. web pages) none of the data or 
configuration files need be accessible via a web server. File naming for  
MapServer follows two rules:

1. Files may be given using their full system path. *or*
2. Files may be given using a relative path where the path is relative to 
   the location of the file they are being referenced from.

So, for files referenced in the Mapfile they can be given relative
to the location of the Mapfile. Same holds true for symbol sets and font sets.

.. index::
   single: Temporary files

Temporary  Files
----------------

MapServer also can produce a number of files (i.e. maps, legends, scalebars, etc...). 
These files **must** be accessible using a web server. To accomplish this 
MapServer creates these files in a scratch directory. The location of that 
directory is given using the IMAGEPATH and IMAGEURL parameters in the web 
section of a Mapfile. The scratch directory must be writable by the user that 
the web server runs under, usually *nobody*. It is recommended for security 
reasons that the web user own the scratch directory rather than making it 
world writable. The scratch area will need to be cleaned periodically. 
On busy sites this may need to happen several times an hour. Here's an 
example shell script that could be run using *cron*:

::

    #!/bin/csh

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


Windows
#######

The following *.bat* file can be used in 'Scheduled Tasks' to remove these 
temporary images daily:

::

    REM this script deletes the contents of the ms_tmp directory 
    REM (i.e. the MapServer-created gifs)
    
    cd D:\ms4w\tmp\ms_tmp
    echo Y | del *.*
