in reply to Suggestions on cleaning up session files

In both sh and perl scripts, for files that have the same expected longevity as the script itself, I tend to create temporary files with the creating PID in the filename and then remove these files at the end of the script - either via a trap command or an END block.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: Suggestions on cleaning up session files
by mr_mischief (Monsignor) on Mar 19, 2009 at 18:12 UTC
    Often in a CGI web application a user's session outlives several program invocations. It's important not to log a user out of a web application before the stated session time limit. Users are fickle beasts with a ravenous appetite for support techs. Please don't taunt them with easy access to the support department through a bug report.

    For temporary files that really don't outlive a single program, File::Temp can give you an open file handle for a file that will automatically get cleaned up without predictably placing the PID number in the file name. Temp file naming collisions are a security risk.