I'm running an embedded system using a Yocto derived Linux distro. kernel version:4.1.15-2.0.0.

We need to manage the logs and do so with logrotate. The requirements are that we have 72 hours of logs, one file for each hour (modified here to rotate every 5 minutes for test purposes). This so the customer can offload specific logs for stipulated hours of operation. They want it to be rock solid since the only way to access operational information is via the logs and these log files are uploaded via an application we have provided.

I have here the logrotate.conf file:

/var/log/messages {
    create 700 root root
    rotate 72
    maxage 4
        /bin/cp /var/volatile/log/messages /home/root/logs/

I run the logrotate system via a contab entry which executes a conjob every hour. Here is the entry in crontab:

*/5 * * * * /etc/logrotateScript.sh

(Note: I've changed the cron job to run every 5 minutes for testing purposes)

And of course here is the contents of the script file:

/usr/sbin/logrotate -f /etc/logrotate.conf

So, this works... er uhm mostly!!

What I sometimes get is a missing file from the sequence. What I mean is for instance, this:

root@imx6qrsb6410a2:~# ls -lh /var/log/
-rw-r--r--    1 root     root           0 Jan  9 17:31 boot
-rw-r--r--    1 root     root       25.7K Jan  9 17:31 dmesg
-rw-r--r--    1 root     root         292 Jan  9 17:31 lastlog
-rwx------    1 root     root       32.8M Jan  9 18:49 messages
-rwx------    1 root     root       34.9M Jan  9 18:45 messages.0
-rw-r--r--    1 root     root         314 Jan  9 18:45 messages.1.gz
-rw-r--r--    1 root     root         313 Jan  9 18:00 messages.10.gz
-rw-r--r--    1 root     root         314 Jan  9 17:55 messages.11.gz
-rw-r--r--    1 root     root         302 Jan  9 17:50 messages.12.gz
-rw-r--r--    1 root     root         379 Jan  9 17:45 messages.13.gz
-rw-r--r--    1 root     root         338 Jan  9 17:40 messages.14.gz
-rw-r--r--    1 root     root         406 Jan  9 17:35 messages.15.gz
-rw-r--r--    1 root     root         313 Jan  9 18:40 messages.2.gz
-rw-r--r--    1 root     root         312 Jan  9 18:30 messages.4.gz
-rw-r--r--    1 root     root         314 Jan  9 18:25 messages.5.gz
-rw-r--r--    1 root     root         357 Jan  9 18:20 messages.6.gz
-rw-r--r--    1 root     root         307 Jan  9 18:15 messages.7.gz
-rw-r--r--    1 root     root         312 Jan  9 18:10 messages.8.gz
-rw-r--r--    1 root     root         311 Jan  9 18:05 messages.9.gz

You can see that the messages.3.gz file is missing. Also the time interval shows that messages.3.gz should have been created at 18;45 so there was a 10 minute interval in which logrotate did not do it's thing.

I've looked at the contents of the 2 files that are on both sides of the missing file and the data is definitely missing.

What circumstances can occur that will cause logrotate to not be able to do its task? I've also noticed this occurring only for messages.3.gz which is very strange. No other applications are touching the messages.#.gz files, all are only writing to messages.

Any help or observations would be greatly appreciated.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.