From: Sascha Silbe on
Hi!

I'd like logrotate to move old (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).
Lastaction would be an option, but then I'd need to duplicate the entire
rotation / removal logic (configured per logfile).
Maybe someone has a better idea?

CU Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/
From: Frank Lin PIAT on
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


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org