When to use sharedscripts in a Logrotate Configuration?
Hello All,
OS: SLES 11.3 x86_64
Should I be using the sharedscripts config command for my logrotate configuration, given the info below?
I made it so the server sending the log data will do Syslog pushes of 3 types of logs to my SLES server, and all 3 logs will be written into the same directory.
These log files are called:
I then have the following configured for Logrotate for those 3 logs, see below...
Logrotate Configuration File: /etc/logrotate.d/host1_logs
I was a little bit confused whether or not I needed to have the sharedscripts command in there or not for my given configuration.
Would I want this to execute only once since it's rotating 3 log files (*sharedscripts) or have it run each time one of those 3 log files are rotated (*nosharedscripts)?
Have a look at the man page:
man logrotate / man logrotate.conf .
You are on the right track. Sharedscripts portion reproduced here.
sharedscripts
Normally, prerotate and postrotate scripts are run for each log which is rotated and the absolute path to the log file is passed as first argument to the script. That means a single script may be run multiple times for log file entries which match multiple files (such as the /var/log/news/* example). If sharedscripts is specified, the scripts are only run once, no matter how many logs match the wildcarded pattern, and whole pattern is passed to them. However, if none of the logs in the pattern require rotating, the scripts will not be run at all. If the scripts exit with error, the remaining actions will not be executed for any logs. This option overrides the nosharedscripts option and implies create option.
Your use looks correct to me.
Cheers,
Nandan
This User Gave Thanks to nandanlbhat For This Post:
Hi Nandan, thanks for the reply, much appreciated!
Ok, so if I have 3 logs that will match my logrotate configuration section, shown in my OP, and they are all going to be rotated at the same time (*since I'm using daily instead of rotating on size) then using sharedscripts would be ok to restart syslog just the one time instead of restarting it 3 separate times.?
If that's correct, then I guess I would want to use that config command....
On re-reading the blurb about sharedscripts, it looks like sharedscripts will trigger if at least one log matches the criteria in your config. On the flip side, no sharedscripts will run, if none of the logs match the criteria.
Daily means your specified logs are getting evaluated every day, even though logrotate might run at a higher frequency.
And yes, syslog will reload only once when all three logs get rotated on the daily schedule.
Nandan
This User Gave Thanks to nandanlbhat For This Post:
Hi, I have a problem with logrotate at Centos 7.
My logrotate is configured with "rotate 0" to Apache logs, so it should never keep logs when rotating, just removing them and replacing by new empty ones at every rotation. But for some reason, once in a while, I see that logrotate is creating... (0 Replies)
Hi all,
i would like to have a configuration on log rotate that will gzip my log files with date pattern %Y-%m-%d
move these files to an olddir, but i want to avoid that the logrotate removes my files from old dir newer than 180 days
i applyied this config
#logrotate config to compress files... (3 Replies)
Hi Admins.
I have installed logrotate rpm on Aix 6.1.
After the installation of rpm, I don't find /etc/logrotate.conf file and /etc/logrotate.d dir .
The config file is located in /opt/freeware/etc/logrotate.conf.
When I ran
logrotate -v /opt/freeware/etc/logrotate.conf
I get below... (2 Replies)
I have written script which is working in Home directory perfectly and also compressing log files and rotating correctly. But, when i try to run script for /var/log/ i am able to get compressed log files but not able to get rotation of compressed log files. Please suggest.
I am using below command... (5 Replies)
Hi All,
Can any one let me me know if i run /usr/sbin/logrotate /etc/logrotate.conf will it read the whole /var/log/messages or it just see the time stamp of message file & then rotate the logs.
Just wants to know is logrotation based on messages file contents or messages file time stamp.
... (1 Reply)
Hello Experts,
I have an apache 2.2.17 on solaris 10 that I am not sure if I, could list the following in the global settings in httpd.conf. I tested it in the Virtual host section of httpd.conf and, it works but, not sure if I can do it in the global settings.
Any help would be greatly... (0 Replies)
Hi I am trying to rotate specific log by using logrotate function in unix
I have made following entry in the /etc/logrotate.conf file
/var/log/testlog/debug_log {
daily
rotate 7
create
compress
}
But only issue is that my other logs like /var/log/messages,... (2 Replies)
Hi,
I have the following configuration file:
/logs/system/mindundi/* {
rotate 0
daily
missingok
sharedscripts
postrotate
find /logs/system/mindundi/ -name "*log" -mtime +15 -exec /bin/rm -f {} \;
endscript
}
I want to save only... (6 Replies)
Hi there,
I want to rotate the logfiles which are located in /var/log/jboss/tomcat*
so I have created a file named as 'tomat' in /etc/logrotate.d/tomcat with the following content.
# cat /etc/logrotate.d/tomcat
/var/log/jboss/tomcat_access_log*.log {
daily
nocreate
... (2 Replies)