I saw this command in our cron. Was wondering what it really does. I
get lost after the part that looks in /export/home/oracle for files
starting with the date........
/bin/find /export/home/oracle -name `date +\%Y`\*.* -a -mtime +20 -a !
-type d -exec rm -f {} \;
Thanks!
It looks for stuff in that oracle subdirectory that:
o with the name beginning with the current 4 digit year (date
+\%Y)
and (-a)
o that is older than 20 days (mtime +20)
and (-a)
o that is NOT a directory (hence the ! character)
and it wacks it (rm -f).
Best Regards,
--
Todd H.
http://www.toddh.net/
Oh, I forgot to mention that you can find the details of all this in
the man page for find.
$ man find
find ... incredible damned tool. You can do nearly anything with it.
And contains a dot.
There's a bug though it should have bee
-name "$(date +%Y)*.*"
otherwise, if there's a file called 2006*.foo in the current
directory, your shell would have expanded than.
> and (-a)
> o that is older than 20 days (mtime +20)
> and (-a)
>
> o that is NOT a directory (hence the ! character)
>
> and it wacks it (rm -f).
[...]
--
Stéphane
There seems to be a second bug: if the files are named as per the date
they are created, then I think this cron will never be able to delete
files created between the 11th and 31st of December. By the time those
files match the -mtime criteria, they would stop matching the -name
criteria (since they year would have changed).
Binand