rm and old rpms

Frantisek Hanzlik franta at hanzlici.cz
Sun Sep 19 18:36:06 UTC 2010


Frank Murphy wrote:
> Hi,
>
> Looking for a method to remove old rpms from a local repo using mtime,
> as *fcX cannot be used in this instance.
>
> It will end up being run as a daily cron job.
>
> Does this look ok?
> find /path/local.repo/*.rpm  -mtime +200 -exec rm {} \;
>

find /path/local.repo -name '*.rpm' -mtime +200 -exec rm {} \;

is OK; when there is many files to remove this maybe faster:

find /path/local.repo -name '*.rpm' -mtime +200|xargs -r rm -f

When /path contains spaces or other "bad" chars (RPM files hasn't them) 
then You should use:

find /path/local.repo -name '*.rpm' -mtime +200 -print0|xargs -r0 rm -f

Franta Hanzlík


More information about the users mailing list