[ale] bash script

James P. Kinney III jkinney at localnetsolutions.com
Tue Sep 11 10:48:12 EDT 2007


How about just a single find that digs down beginning with
/var/www/zm/events and then does the rm -f as you have already.

find /var/www/zm/events ! "*.log" -mtime 5 -print | rm -f $1

Or you can iterate over the directories using a for loop
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do ...

On Tue, 2007-09-11 at 10:18 -0400, Marvin, International Martian of
Mystery wrote:
> I'd like some feedback/critique for a script I'm running as a cron job
> daily on a box I administrate.  It's supposed to delete all the files it
> finds that are 5 days or older.  
> 
> This is what I've come up with:
> 
> 
> 
> 
> 
> 
> 
> #! /bin/sh
> 
> ## Remove ZoneMinder events cache
> ## There's gotta be a better way  to
> ## do this!
> 
> EXECUTE="/usr/bin/find ./ ! -name "*.log" -mtime 5  -print | /sbin/rm
> -Rf $1"
> 
> 
> cd /var/www/zm/events/1
>         $EXECUTE
> cd /var/www/zm/events/2
>         $EXECUTE
> cd /var/www/zm/events/3
>         $EXECUTE
> cd /var/www/zm/events/5
>         $EXECUTE
> cd /var/www/zm/events/6
>         $EXECUTE
> cd /var/www/zm/events/9
>         $EXECUTE
> cd /var/www/zm/events/10
>         $EXECUTE
> cd /var/www/zm/events/11
>         $EXECUTE
> cd /var/www/zm/events/12
>         $EXECUTE
> cd /var/www/zm/events/13
>         $EXECUTE
> cd /var/www/zm/events/14
>         $EXECUTE
> cd /var/www/zm/events/15
>         $EXECUTE
> 
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
> 
-- 
James P. Kinney III          
CEO & Director of Engineering 
Local Net Solutions,LLC        
770-493-8244                    
http://www.localnetsolutions.com

GPG ID: 829C6CA7 James P. Kinney III (M.S. Physics)
<jkinney at localnetsolutions.com>
Fingerprint = 3C9E 6366 54FC A3FE BA4D 0659 6190 ADC3 829C 6CA7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part




More information about the Ale mailing list