Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
To rotate when the log reaches a give size rather than daily, replace the string daily with the size directive.
"size size
Log files are rotated when they grow bigger then size bytes. If
size is followed by M, the size if assumed to be in megabytes.
If the k is used, the size is in kilobytes. So size 100, size
100k, and size 100M are all valid.
"
So in your case for 2M you would do something along the lines of:
Edit: unspawn is correct in stating that for the above to work you would need to run logrotate more frequently. Depending on how/frequent you are running and how many messages you are received each day, you could easily rotate through the all 99 archives.
From the man page:
" Normally, logrotate is run as a daily cron job. It will not modify a
log multiple times in one day unless the criterium for that log is
based on the log’s size and logrotate is being run multiple times each
day....
"
Last edited by irabinovitch; 10-17-2011 at 12:59 PM.
If logrotate only runs once a day then the "rotate" directive will ensure the log gets rotated 99 times but combining it with "size" makes no sense as the log will be rotated anyway. OTOH if /var/log/messages fills that quickly that you need to rotate the log several times a day then "size" does work but it'll hit the "rotate" limit several times quicker than with a daily run. What's a 2MB size anyway these days?...
So if i am correct I should copy the /etc/cron.daily/logrotate script to /etc/cron.hourly ad the very minimum to get it to check the logs file sizes on an hourly basis.
/usr/sbin/logrotate /etc/logrotate.d/messages <<<< changed this line...
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
Well i did as mentioned above but I am still getting the pesky emails... So I am sure something is missing. Have not had a change to get back to it until now.
Cron <root@myserver> run-parts /etc/cron.daily
/etc/cron.daily/logrotate:
error: syslog:1 duplicate log entry for /var/log/messages
error: found error in /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron , skipping
Here is my syslog.conf
etc]# cat syslog.conf
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
#####*.info;mail.none;authpriv.none;cron.none /var/log/messages
*.info;mail.*;authpriv.*;cron.* /var/log/messages
*.info;mail.none;authpriv.none;cron.none @myserver99
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.