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

Re: logrotate: olddir on different device?



On Sat, 2009-09-26 at 11:59 +0200, Sascha Silbe wrote:
> ld (compressed) logfiles to a directory on a 
> different device (from SD card to hard disk in this case).
> Unfortunately 
> the "olddir" config option only works if both directories are on the 
> same device (probably for easier handling of the first rotate step).

That's probably to make sure that moving the file is immediate/atomic.

> Lastaction would be an option, but then I'd need to duplicate the
> entire rotation / removal logic (configured per logfile).

This might still be an option, if you set "dateext" in logrotate (the
old files are then named mylogfile.YYYYMMDD*)

Then periodically run something like:
  cd /path/to/logs ; ls -1 mylog* | sort -r | sed '1,5d' | xargs echo rm
(This assume you want to preserve the 5 last log files)

Once you have tested it, you can replace "echo rm" with "rm" ;)

> Maybe someone has a better idea?

There are probably better ideas, but this quick hack should work.

Regards,

Franklin


Reply to: