sean finney <[EMAIL PROTECTED]> [2003-01-02 19:21:14 -0500]: > instead of using date +%s, incrementing, and sleep, how about > using date +%s%N? what you can do is something like
Interesting suggestion. Note that %N is only available in the sid version in coreutils and not the stable woody version. It is a new feature. > while [ ! $doneyet ]; do > FN="`date +%s%N`.jpg" > [ ! -f $FN ] && doneyet=1; > done > - if there is a collision, it simply tries again immediately (and will > get a new value from %N) But if there is a lot of activity then this will 'spinlock' until it generates a new filename. There is no sleep there or anything so it will keep spinning at full cpu until the time changes to a unique name. The faster the cpu the more cycles available to spin. And if there were several mail processes arriving at the same time this is even likely. Therefore I don't like it as much. Half baked idea: How about using 'mktemp'? If all you are looking for is a temporary filename then that command will provide unique names without this set of problems. By default in /tmp but you can always put it in the current directory with 'mktemp -p ./'. Bob
msg22180/pgp00000.pgp
Description: PGP signature