-1

I am working on a java application running in Ubuntu Server (16.04) which copies log files from certain folders and consolidate then when user closes the session. In ubuntu server rsyslog filters and keeps generating logs from different devices (external) and stores logs in a folder.

After the files copied by java application I need to rotate the logs. For that I am planning to use logrotate program. I created a config to rotate this files once a session is closed (user triggers this by closing the session in application).

The files created in the folder (/media/content/persist/log/external/) as below:

-rwxr-xr-x 1 syslog syslog 283 Jul 1 20:49 192.168.10.100-syslog.log -rwxr-xr-x 1 syslog syslog 24K Jul 1 21:25 192.168.10.11-syslog.log -rwxr-xr-x 1 syslog syslog 8.6K Jul 1 21:25 192.168.10.10-syslog.log -rwxr-xr-x 1 syslog syslog 439K Jul 1 21:40 192.168.10.12-syslog.log 

Log rotate config: **File: rsyslog-fc-rotate.conf **

/media/content/persist/log/external/*-syslog.log { rotate 4 maxsize 5M compress missingok notifempty postrotate invoke-rc.d rsyslog rotate > /dev/null endscript } 

When I run logrotate manually I am getting the result below without any rotation is being happend

> logrotate -f -d -v rsyslog-fc-rotate.conf reading config file rsyslog-fc-rotate.conf Handling 1 logs rotating pattern: /media/content/persist/log/external/*-syslog.log forced from command line (4 rotations) empty log files are not rotated, log files >= 5242880 are rotated earlier, old logs are removed considering log /media/content/persist/log/external/192.168.10.100-syslog.log log needs rotating considering log /media/content/persist/log/external/192.168.10.10-syslog.log log needs rotating considering log /media/content/persist/log/external/192.168.10.11-syslog.log log needs rotating considering log /media/content/persist/log/external/192.168.10.12-syslog.log log needs rotating rotating log /media/content/persist/log/external/192.168.10.100-syslog.log, log->rotateCount is 4 dateext suffix '-20240701' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' renaming /media/content/persist/log/external/192.168.10.100-syslog.log.4.gz to /media/content/persist/log/external/192.168.10.100-syslog.log.5.gz (rotatecount 4, logstart 1, i 4), renaming /media/content/persist/log/external/192.168.10.100-syslog.log.3.gz to /media/content/persist/log/external/192.168.10.100-syslog.log.4.gz (rotatecount 4, logstart 1, i 3), renaming /media/content/persist/log/external/192.168.10.100-syslog.log.2.gz to /media/content/persist/log/external/192.168.10.100-syslog.log.3.gz (rotatecount 4, logstart 1, i 2), renaming /media/content/persist/log/external/192.168.10.100-syslog.log.1.gz to /media/content/persist/log/external/192.168.10.100-syslog.log.2.gz (rotatecount 4, logstart 1, i 1), renaming /media/content/persist/log/external/192.168.10.100-syslog.log.0.gz to /media/content/persist/log/external/192.168.10.100-syslog.log.1.gz (rotatecount 4, logstart 1, i 0), renaming /media/content/persist/log/external/192.168.10.100-syslog.log to /media/content/persist/log/external/192.168.10.100-syslog.log.1 running postrotate script running script with arg /media/content/persist/log/external/192.168.10.100-syslog.log: " invoke-rc.d rsyslog reload > /dev/null " compressing log with: /bin/gzip removing old log /media/content/persist/log/external/192.168.10.100-syslog.log.5.gz error: error opening /media/content/persist/log/external/192.168.10.100-syslog.log.5.gz: No such file or directory 

This message is repeating for all the files and no rotation is happening. Not sure why it is failing.

In my application with this config, for every session close the files needs to be rotated. This logrorate call will be coming from a java service.

4
  • Ubuntu 16.04 - added it to the question also Commented Jul 2, 2024 at 14:51
  • 1
    You understand that 16.04 is pretty much out of support now? Commented Jul 2, 2024 at 14:56
  • Yes. But it's our platform for thousands of servers and no other option.. :) Commented Jul 2, 2024 at 21:32
  • That's an even more important reason to be moving away from it to a supported system. Can you afford for your thousands of servers to be impacted by a critical issue? Commented Jul 3, 2024 at 7:05

1 Answer 1

1

This is to be expected as you're using the -d flag. The documentation (see man logrotate) writes,

-d, --debug Turn on debug mode, which means that no changes are made to the logs and the logrotate state file is not updated. Only debug messages are printed

1
  • Oh my bad. Didn't know this flag does this. Thanks. Now it is working as expected. Commented Jul 2, 2024 at 21:30

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.