cron.daily problem

I am confused about cron.daily in my RedHat 9.0 system.

If I see when it will be executed :

  # 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

Then, the cron.daily will be executed everyday at 04:02 AM, right?

If I look into /etc/cron.daily, I saw this :

  # cd /etc/cron.daily
  # ls
  00-logwatch  0anacron  logrotate  makewhatis.cron  rpm  slocate.cron  tmpwatch

It runs "logrotate". So, in my understanding, the log files will be rotated EVERYDAY (depends on /etc/logrotate.conf).

Here is the content of /etc/logrotate.conf :

  # cat /etc/logrotate.conf
  weekly
  rotate 4
  create
  #compress
  include /etc/logrotate.d
  # no packages own wtmp -- we'll rotate them here
  /var/log/wtmp {
      monthly
      create 0664 root utmp
      rotate 1
  }

Then, logrotate will execute all configuration in /etc/logrotate.d, for example :

# cat /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

But why, those logs are NOT rotated everyday ?

# ls -l /var/log
-rw-------    1 root     root         8693 Oct 30 08:01 cron
-rw-------    1 root     root        14349 Oct 26 04:02 cron.1
-rw-------    1 root     root        14464 Oct 19 04:02 cron.2
-rw-------    1 root     root         7153 Oct 12 04:02 cron.3
-rw-------    1 root     root        10162 Oct 30 07:38 messages
-rw-------    1 root     root        61375 Oct 26 02:48 messages.1
-rw-------    1 root     root        51918 Oct 19 01:38 messages.2
-rw-------    1 root     root        51224 Oct  9 21:41 messages.3

See the date? In my understanding above, it should be rotated everyday. But why NOT ?

I checked in 3 RedHat 9.0 boxes, and all are the same situation. Am I missing something or misunderstood ?

Because I tried to run webalizer through logrotate of httpd :

/var/log/httpd/*log /home/www/mydomain.com/logs/*log {
    missingok
    notifempty
    sharedscripts
    prerotate
        /usr/bin/webalizer
    endscript
    postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}

But with this situation, it does not executed :(

So I just confused. Please help.

Thank you
nova2002Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlanBellCommented:
This snippet from the logrotate manpage should explain whats going on:

weekly Log files are rotated if  the  current  weekday  is
              less  then  the  weekday of the last rotation or if
              more then a week has passed since  the  last  rota-
              tion. This is normally the same as rotating logs on
              the first day of the week, but it works  better  if
              logrotate is not run every night.

Alan.
0
nova2002Author Commented:
So, if I want to execute specific logrotate daily, can I overwrite that ?

For example :

/var/log/httpd/*log /home/www/mydomain.com/logs/*log {
    daily
    missingok
    notifempty
    sharedscripts
    prerotate
        /usr/bin/webalizer
    endscript
    postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}

Will this works?
0
AlanBellCommented:
What I would do is add that snippet above into a file /etc/logrotate.d/ called http, web or whatever you want.

Because the line "include /etc/logrotate.d" points to a directory logrotate will include all files in that directory and because your "daily" option is specific to those log files it will override the global "weekly" option.

Alan.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

KubrikCommented:
>> Because I tried to run webalizer through logrotate of httpd :

What do you want to do?
Starting webalizer daily?

Create a file (chmoded +x) under /etc/cron.daily with this line:

#!/bin/sh
/usr/bin/webalizer -c /etc/webalizer/yourconf.conf
0
nova2002Author Commented:
Kubrik,
Yes, basically I want to do that.

But I also want my apache logs will be ROTATED. So, I came up with the idea above, using logrotate to run webalizer. Because I want to make sure that the webalizer will process the correct log.

0
KubrikCommented:
Ok, then add
 daily
as you had wrote before.

Because when no "daily" or "weekly" or "monthly" is specified in a directive file like apache one:

/var/log/httpd/*log /home/www/mydomain.com/logs/*log {
    missingok
    notifempty
    sharedscripts
    prerotate
        /usr/bin/webalizer
    endscript
    postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}

default is WEEKLY taken from logrotate.conf :

# cat /etc/logrotate.conf
  weekly   <-----------------------------
  rotate 4
  create
  #compress
  include /etc/logrotate.d

bye.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GnsCommented:
Basically, what you suggest (the daily modification) would do what you want. Separating the different "domains"(:-) of httpd logs into separate logrotate.d files (as AlanBell suggests) would be nicem since then you'd be able to retain the "slow rotation" of the main service logs. Or running webalizer from a separate cronjob (as Kubrik suggests)  would also work nicely (keeping both main logs and mydomain.com logs at "weekly" rotations).
But as said, you'd be fine with the "daily". (I'm buting in, since I suggested logrotate to nova2002 in http://www.experts-exchange.com/Operating_Systems/Linux/Q_20780811.html ...)

-- Glenn
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Installation

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.