[SOLVED] Logrotate Logs not rotating Ubunutu 12.4 LTS
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am a rookie when it comes to Linux, and I have been tasked with creating a syslog server using Ubuntu to hold logs for 100+ networking devices. I wanted a separate log for each source ip address and dynamically created with the date. I achieved this with the following in /etc/rsyslog.conf
Below is the relevant section of /etc/logrotate.d/rsyslog. (IP addresses replaced with XXX or YYY). I tried 2 different settings for 2 different logs and neither works.
-rw-r--r-- 1 root root 0 Dec 12 06:26 XXX.XXX.XXX.XXX.2012-12-11.log
-rw-r--r-- 1 root root 3236940 Dec 11 23:59 XXX.XXX.XXX.XXX.2012-12-11.log.1
-rw-r--r-- 1 root root 0 Dec 13 06:35 XXX.XXX.XXX.XXX.2012-12-12.log
-rw-r--r-- 1 root root 7033328 Dec 12 23:59 XXX.XXX.XXX.XXX.2012-12-12.log.1
-rw-r--r-- 1 root root 2369832 Dec 12 06:26 XXX.XXX.XXX.XXX.2012-12-12.log.2
-rw-r--r-- 1 root root 0 Dec 14 06:31 XXX.XXX.XXX.XXX.2012-12-13.log
-rw-r--r-- 1 root root 6566549 Dec 13 23:59 XXX.XXX.XXX.XXX.2012-12-13.log.1
-rw-r--r-- 1 root root 0 Dec 15 06:51 XXX.XXX.XXX.XXX.2012-12-14.log
-rw-r--r-- 1 root root 8569767 Dec 14 23:59 XXX.XXX.XXX.XXX.2012-12-14.log.1
-rw-r--r-- 1 root root 0 Dec 16 06:46 XXX.XXX.XXX.XXX.2012-12-15.log
-rw-r--r-- 1 root root 9113066 Dec 15 23:59 XXX.XXX.XXX.XXX.2012-12-15.log.1
-rw-r--r-- 1 root root 0 Dec 17 06:28 XXX.XXX.XXX.XXX.2012-12-16.log
-rw-r--r-- 1 root root 13063562 Dec 16 23:59 XXX.XXX.XXX.XXX.2012-12-16.log.1
-rw-r--r-- 1 root root 0 Dec 18 06:47 XXX.XXX.XXX.XXX.2012-12-17.log
-rw-r--r-- 1 root root 7929472 Dec 17 23:59 XXX.XXX.XXX.XXX.2012-12-17.log.1
-rw-r--r-- 1 root root 4438687 Dec 18 13:58 XXX.XXX.XXX.XXX.2012-12-18.log
-rw-r--r-- 1 root root 0 Dec 14 06:31 YYY.YYY.YYY.YYY.2012-12-06.log
-rw-r--r-- 1 root root 6843 Dec 6 23:17 YYY.YYY.YYY.YYY.2012-12-06.log.1
-rw-r--r-- 1 root root 0 Dec 14 06:31 YYY.YYY.YYY.YYY.2012-12-07.log
-rw-r--r-- 1 root root 23574 Dec 7 23:17 YYY.YYY.YYY.YYY.2012-12-07.log.1
-rw-r--r-- 1 root root 0 Dec 14 06:31 YYY.YYY.YYY.YYY.2012-12-08.log
-rw-r--r-- 1 root root 7693 Dec 8 23:17 YYY.YYY.YYY.YYY.2012-12-08.log.1
-rw-r--r-- 1 root root 0 Dec 14 06:31 YYY.YYY.YYY.YYY.2012-12-09.log
-rw-r--r-- 1 root root 8020 Dec 9 23:17 YYY.YYY.YYY.YYY.2012-12-09.log.1
-rw-r--r-- 1 root root 0 Dec 14 06:31 YYY.YYY.YYY.YYY.2012-12-10.log
-rw-r--r-- 1 root root 10790 Dec 10 23:17 YYY.YYY.YYY.YYY.2012-12-10.log.1
-rw-r--r-- 1 root root 0 Dec 14 06:31 YYY.YYY.YYY.YYY.2012-12-11.log
-rw-r--r-- 1 root root 19424 Dec 11 23:17 YYY.YYY.YYY.YYY.2012-12-11.log.1
-rw-r--r-- 1 root root 0 Dec 14 06:31 YYY.YYY.YYY.YYY.2012-12-12.log
-rw-r--r-- 1 root root 7842 Dec 12 23:17 YYY.YYY.YYY.YYY.2012-12-12.log.1
-rw-r--r-- 1 root root 0 Dec 14 06:31 YYY.YYY.YYY.YYY.2012-12-13.log
-rw-r--r-- 1 root root 16021 Dec 13 23:17 YYY.YYY.YYY.YYY.2012-12-13.log.1
-rw-r--r-- 1 root root 0 Dec 15 06:51 YYY.YYY.YYY.YYY.2012-12-14.log
-rw-r--r-- 1 root root 13646 Dec 14 23:17 YYY.YYY.YYY.YYY.2012-12-14.log.1
-rw-r--r-- 1 root root 0 Dec 16 06:46 YYY.YYY.YYY.YYY.2012-12-15.log
-rw-r--r-- 1 root root 14604 Dec 15 23:17 YYY.YYY.YYY.YYY.2012-12-15.log.1
-rw-r--r-- 1 root root 0 Dec 17 06:28 YYY.YYY.YYY.YYY.2012-12-16.log
-rw-r--r-- 1 root root 16194 Dec 16 23:17 YYY.YYY.YYY.YYY.2012-12-16.log.1
-rw-r--r-- 1 root root 0 Dec 18 06:47 YYY.YYY.YYY.YYY.2012-12-17.log
-rw-r--r-- 1 root root 17130 Dec 17 23:17 YYY.YYY.YYY.YYY.2012-12-17.log.1
-rw-r--r-- 1 root root 18255 Dec 18 13:45 YYY.YYY.YYY.YYY.2012-12-18.log
So, initially I want to be able to delete all files that are older than X day(s). And modify this value based on the device. In this example, I want XXX to delete files older than 1 day and YYY to delete files older than 30. It seems like it is renaming the old file with a .1 at the end, creating a new file that is empty, and that is it. I've researched this for hours and tried various things found in the man pages but nothing seems to produce the result that I want. Any help would be appreciated. If I didn't explain something correctly, please let me know.
Im sorry it has taken so long to reply - I have been out for Christmas. I attempted your suggestions but was still unsuccessful. I came to the idea that maybe the dynamic portion of the code was the issue %HOSTNAME%.%$YEAR%-%$MONTH%-%$DAY%.log and instead reverted to an individual log as so:
Now it doesn't appear to be rotating at all... It created one empty file FW.log.1 and just kept appending the original file for many days. Also, I'm not sure if this would cause anything, but when I deleted the original directory, modified this code, and first restarted the rsyslog service, the /var/log/remotehosts directory denied me access. So I did chmod 777 /var/log/remotehosts..... Any ideas? I appreciate the help that you have already offered.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.