02-18-06 03:40 AM
On 15 Feb 2006 08:35:47 -0800, Doug Freyburger wrote:
> Tony wrote:
>
> Maybe better to drop the -name clause so you include
> names .* in the clean-up.
With a UNIX conformant find, -name '*' has no effect, it will
not exclude dot files. Some old find implementations will not be
POSIX conformant and behave as you say. In any case, it's true
that it doesn't make sense to add "-name '*'".
> Definitely better to use
> -mtime over -ctime for clean-up. Change time is when
> the inode changes (chown, chgrp, chmod and data
> changes large enough to cause (de)allocations of data
> blocks).
Any read or right to the file will modify the inode time as it
will change the atime or mtime, so modify the inode.
The ctime is modified at least everytime either of the other
times is modified.
> Modify time tracks data modification, more
> likely to be what you want:
Yes, though utime will modify it without any modification being
done, but that's on purpose.
> find temp_dir -depth -type d -mtime +3 -print | while read i ; do
> COUNT=` /bin/ls -al ${i} | wc -l `
> if [ $COUNT -gt 3 ] ; then
> rmdir ${i}
> fi
> done
Don't do such things on a temp dir, with world write access. If
that script is run by root, it's a security hole (it will
allow anyone to remove any empty directory in the system.
--
Stephane
[ Post a follow-up to this message ]
|