Bug 718

Summary: Allow logrotate to use a different file system from the original logs
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Gary Thomas <gary>
Component: meta-yoctoAssignee: Robert Yang <liezhi.yang>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: Low CC: liang.li2, liezhi.yang, poky.bs.watcher, poky.watcher, richard.purdie, sgw, yi.zhao
Version: unspecified   
Target Milestone: 1.2 M4   
Hardware: x86   
OS: Multiple   
Whiteboard: (P3) (QA testing completed) Done
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Gary Thomas 2011-02-14 09:18:51 UTC
Current implementations of logrotate restrict the location of the destination directory to be on the same file system as the files being rotated out.  This is purely for implementation simplicity - a hard link is used.  However, it makes it difficult to use when the main log files live in ramdisk and one wants to preserve them in FLASH.

Given that in many cases the logs are compressed as they are being rotated, using hard links doesn't buy much anyway.
Comment 1 Robert Yang 2012-03-02 08:45:41 UTC
Hi Gary,

I think this is because the logrotate uses:

rename(const char *oldpath, const char *newpath);

to rotate the log, the rename can't acrosses the different filesystems,
I will use read and write to replace the rename if you are OK with it,
and will send the patch review next week after enough testing.
Comment 3 liang li 2012-03-12 01:42:15 UTC
verified it on :
git info:6bd23e0faf329f086bb4885991ce5f5d095dac56
git branch: poky/master

use following steps:
1. set build env,run "source ./oe-init-build-env builddir".
2. add lines to the conf/local.conf of builddir.
   DISTRO_EXTRA_RDEPENDS += "logrotate"
3. run "bitbake core-image-sato".
4. boot up image and add following configuration option to "/etc/logroate.conf":
   ...
   /var/log/wtmp {
    monthly
    create 0664 root utmp
        minsize 1M
    olddir /home/root/logrotate_dir
    rotate 1
}
   ...
   and "/home/root" is on different filesystem to which "/var/log/wtmp" is on.
5. run "logrotate -f /etc/logrotate.conf".

wtmp-20120312 is found in /home/root/logrotate_dir.

test env:
host : ubuntu 11.10 x86_64
kernel : 3.0.0-16-generic #29-Ubuntu SMP