in reply to Re: Planning a Disk CleanUp Script
in thread Planning a Disk CleanUp Script

A tip.

Use random integers, not sequential ones.

With sequential integers you have a race conditions. If 2 instances are trying to start at once, both can choose the same name and try to write to it, with bad results. Choose random integers and then test whether that one exists already and the odds of a bad race falls by several orders of magnitude.

Either that or have the integer in question produced by a single source, such as an autoincrement field in a database.

  • Comment on Re (tilly) 2: Planning a Disk CleanUp Script

Replies are listed 'Best First'.
Re: Re (tilly) 2: Planning a Disk CleanUp Script
by theguvnor (Chaplain) on Jan 15, 2002 at 07:41 UTC

    Thanks for the tip tilly. You are right to suggest random integers for the reasons you have outlined. But I do want to point out that anyone writing such a system should also look to the security section in the Camel on race conditions, and also be sure to use sysopen() rather than relying on an file existence test and open(), for the reasons outlined in the Camel.