delete old logs

Florin Andrei florin at andrei.myip.org
Thu May 10 00:54:52 GMT 2007


I've several web servers that use log4j to generate the logs.

The log file currently appended to is called filename. The older, 
non-current logs are called filename.yyyy-mm-dd-hh.

Obviously, rotation takes place once every hour and it's done 
automatically by log4j. Old logs are never deleted by log4j, something 
else must delete them.

I need to rsync all the filename* files from all web servers 
periodically to a "log server", and a safe copy is made to a backup log 
server. Each web server is running an rsync daemon, and a cron job on 
the main log server cycles through all web servers periodically.

Logs older than X hours must be deleted from the web servers, but only 
provided that a copy already exists on the log server AND another copy 
exists on the backup log server (any log file must exist in at least two 
places after any given rsync transfer).

Because I want to minimize the number of protocols and applications 
involved in the process, I'd like to perform the deletion of old log 
files from the web servers using rsync.
Another reason to do that is that I want to handle everything (log 
transfer, archival, deletion) via one single cron job on the log server, 
instead of various cron jobs on the log server and on each web server, 
in order to minimize collisions.

The problem is, the files that must be deleted are on the sender and the 
rsync documentation that I'm looking at doesn't seem to provide any clue 
as to how to delete files on the sender.

Once some of these conditions are relaxed, the problem appears quite 
solvable (e.g., mount the log directories via NFS and then do rsync and 
deletion over the NFS mount), but first I'd like to make sure that 
there's no way to accomplish everything solely via rsync.

Please enlighten me.

Thanks,

-- 
Florin Andrei

http://florin.myip.org/


More information about the rsync mailing list