Solved

Question on Cronjobs/Logrotate in Linux

Posted on 2011-03-07
7
1,256 Views
Last Modified: 2012-05-11
Hello,

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
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# 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
#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
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.
0
Comment
Question by:ashsysad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 250 total points
ID: 35062165
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.
0
 
LVL 4

Expert Comment

by:l4ncel0t
ID: 35062235
Hello
did you tried that
/usr/sbin/logrotate /etc/logrotate.conf
manually ?
0
 

Author Comment

by:ashsysad
ID: 35062589
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 {
        daily
        create
        missingok
        notifempty
        size 1M
        rotate 4
        nomail
        postrotate
                killall -HUP syslogd
        endscript
}
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:ashsysad
ID: 35062905
To put my question simple....in 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.
0
 

Author Comment

by:ashsysad
ID: 35062921
0
 
LVL 4

Accepted Solution

by:
l4ncel0t earned 250 total points
ID: 35067192
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


0
 

Author Closing Comment

by:ashsysad
ID: 35272565
Thanks for your ideas.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
RHEL6 + dockers - No route to host 7 104
Advice on ESXi 5.1 Health / Storage 1 79
Windows 10 linux VM 30 92
unix shell script 4 39
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question