Question on Cronjobs/Logrotate in Linux


In many of the Linux servers in our environment, we noticed the logfiles such as /var/log/messages, /var/log/secure aren't getting rotated for several months though the config file looks fine (/etc/logrotate.conf). When I check the /etc/crontab, I see the following entries:

[root@orallm72 etc]# cat /etc/crontab

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
[root@orallm72 etc]# cd /etc/cron.daily
[root@orallm72 cron.daily]# ls
00webalizer  0logwatch  cups             logrotate        mlocate.cron  rpm         tmpwatch
0anacron     certwatch  inn-cron-expire  makewhatis.cron  prelink       tetex.cron  tripwire-check
[root@orallm72 cron.daily]# cat logrotate

/usr/sbin/logrotate /etc/logrotate.conf
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
exit 0
[root@orallm72 cron.daily]#

My Questions:

1. What are that entry "run-parts", what does it do ?
2. How can I ensure the "cron.daily" is getting executed without fail everyday and it is executing the 'logrotate' command?

Please let me know if you have any questions.
Who is Participating?
l4ncel0tConnect With a Mentor Commented:
Can you launch  logrotate script in cron.daily ?
Is cron daemon runing ?

If every parts work you shoudn't have problem like that

I usually monitor crond + filesystem usage for this type of problem (with zabbix)

To be more precise you need to know what is the problem with your current configuration

For your logfile maybee you can check the creation date with find.
If ceration date is older than your retention policy in logrotate you likely have a problem

TintinConnect With a Mentor Commented:
1.  run-parts is a utility that executes all the files in the specified directory

2. Check your cron log.  Locations vary depending on your system, but try /var/log/cron.log

Also check the contents of /etc/logrotate.conf and the /etc/logrotate.d directory to see what's configured to be rotated.
did you tried that
/usr/sbin/logrotate /etc/logrotate.conf
manually ?
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

ashsysadAuthor Commented:
Yes, when i try manually with '-f' option, it works fine. But cron.daily is not seems to be executing it daily.
I just want to ensure that in all the servers, the logs are getting rotated properly.

I just created a log file that can be put in /etc/logrotate.conf file. But how would I ensure that cron.daily is executing this properly. Its not practically possible to run "logrotate" command manually everyday.

/var/log/messages {
        size 1M
        rotate 4
                killall -HUP syslogd
ashsysadAuthor Commented:
To put my question all the Linux servers in our environment, how can I check and ensure that Log files are getting rotated properly ?  Cron log may gives me some information but its not practically possible for me to analyse log files in each and every server. We have FUNC server in our setup, using which I can execute some commands simultaneously in all the Linux servers and get the output. However checking log files would be pain.
ashsysadAuthor Commented:
Thanks for your ideas.
All Courses

From novice to tech pro — start learning today.