Re: Find files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Feb 22, 2008 at 9:16 PM, Robert <kerplop@xxxxxxxxxxxxx> wrote:
>
>
>  centos@xxxxxxxxxxxxxxx wrote:
>  > Hi,
>  >
>  > I am trying to delete files that are more than 7 days old. When I
>  > run it interactively it works, no problem, but it does not run
>  > from a file stored in cron.daily. The rest of that daily file
>  > runs properly. [The execute bit is on].
>  >
>  > I don't see anything in the /var/log/messages.
>  >
>  > ---------------------------------------
>  > #!/bin/bash
>  >
>  > find /mnt/iog -type f -name '*.tar.gz' -mtime +7 | xarg rm
>  > ---------------------------------------
>  >
>  > Any idea what am I missing?
>  >
>  Just a shot in the dark:  Cron is kinda partial to absolute paths.
>  Change your 1-liner to:
>
>  /usr/bin/find /mnt/iog -type f -name '*.tar.gz' -mtime +7 | xargs rm
>
>  That, and the "xargs" that Garrick pointed out.
>
>
>  Good luck.
>  _______________________________________________
>  CentOS mailing list
>  CentOS@xxxxxxxxxx
>  http://lists.centos.org/mailman/listinfo/centos
>

You can also do it like this

/usr/bin/find /mnt/iog -type f -name '*.tar.gz' -mtime +7 -print -exec
rm -f {} \;


If you want to log the results that were deleted try this

/usr/bin/find /mnt/iog -type f -name '*.tar.gz' -mtime +7 -print -exec
rm -f {} \; >> mylog 2> /dev/null


-- 
-matt
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux