Question : Script using find in linux

Hi,

I need to modify the log rotation script to move logs older than 7 days from
/usr/local/RealMedia/ads/OpenAd/Logs/ to a directory under /mnt/ads-backup
Gzip logs as usual, and remove backed up logs older than 30 days like usual.
Prune empty directories. Make sure to maintain the same directory structure
(with respect to /usr/local/RealMedia/ads/OpenAd/Logs/) in the backup
directory.

This is the current script we have :

#!/bin/bash

dir="/usr/local/RealMedia/ads/OpenAd/Logs/"

find $dir -type f -mtime +30 -print -exec rm {} \;
find $dir -type l -mtime +30 -print -exec rm {} \;
find $dir -type f -mtime +1 ! -name "*gz" -exec gzip -9 {} \;
find $dir -type d -empty -exec rm -rf {} \;

Answer : Script using find in linux

It looks fine to me.  I have not tested it, however.

I would probably leave the trailing slash off the directory variables.   It doesn't really matter, just $target_dir/{} is more intuitive to me than $target_dir{}.
Random Solutions  
 
programming4us programming4us