logrotate behave unusually, how do I debug?

oslon

Member
Joined
Oct 15, 2023
Messages
38
Reaction score
6
Credits
406
Rich (BB code):
/path/to/logs/*.out {
        su server server
        daily
        copytruncate
        missingok
        rotate 7
        compress
        dateext dateformat -%Y-%m-%d
}

/path/to/logs2/*.log{
        su server server
        daily
        copytruncate
        missingok
        rotate 7
        compress
        dateext dateformat -%Y-%m-%d
        sharedscripts
        postrotate
            /home/server/server/bin/shutdown.sh && /home/server/server/bin/startup.sh
        endscript
}
When I execute this using in server, it behave unusually.
  • sometimes the logs are not stored at all, the file is created, but it's of 0 size.
  • sometimes server get stopped and don't get restarted.
The server that I am using can be tomcat, glassfish/payara or Java servers.(J2EE or something lol).
 


sometimes server get stopped and don't get restarted.
/home/server/server/bin/shutdown.sh && /home/server/server/bin/startup.sh
Make sure your shutdown.sh script doesn't return until the process of shutdown is fully complete,
otherwise you end up starting it prematurely which might mean not starting it at all and thus also not writing any files.

For instance the command to shutdown something might return immediately (async) however to actually shut down might take time.
 
It works fine when I check the config though.
You might want to share code of your shutdown and startup scripts, to see if they can be run the way you specified in logrotate config file.

If not, then at least share only the portion relevant.

Note that && will check for error which btw. won't report a problem of an async command, but this only applies to shutdown script, you have no error checking at all in place for your startup script.
 
Hi,

you can use the debug mode of logrotate to check your config:
Code:
logrotate -d /path/to/your/config
Adding -fv to that may also help you get some clarity of what's happening or why it's doing something or not doing something.
 

Members online


Top