Re: rotatate logs - Apache has anyone got this to rotate at a specific time?

  • From: Chuck Edwards <chuck@xxxxxxxxxxxxx>
  • To: ora-apps-dba@xxxxxxxxxxxxx
  • Date: Fri, 16 Oct 2009 10:01:25 -0700

Run this from the command line:

logrotate -f <path to config file>

That will force a rotation of the logs specified in the config file, even if the parameters wouldn't indicate rotation is needed. If you already use logrotate.d, you can just specify the config file there:

logrotate -f /etc/logrotate.d/<file>

If you run that from cron at midnight, it should do what you are asking. The graceful apache option I used below does not shut down the services and no sessions are disconnected; it simply tells the daemon to re-read the config file.

Chuck



On Oct 16, 2009, at 9:54 AM, kathy duret wrote:

I am using the rotaelog funciton via Linux and it works

The issue is I need to force it at midnight

I can't shutdown the services.

I want to find out how to force a rotatelog at midnight if I can't get the rotatelog function to do it.

Thanks,

Kathy

--- On Fri, 10/16/09, Chuck Edwards <chuck@xxxxxxxxxxxxx> wrote:

From: Chuck Edwards <chuck@xxxxxxxxxxxxx>
Subject: Re: rotatate logs - Apache has anyone got this to rotate at a specific time?
To: ora-apps-dba@xxxxxxxxxxxxx
Cc: oracle-l@xxxxxxxxxxxxx
Date: Friday, October 16, 2009, 10:37 AM

Have you tries using logrotated? It's included in most Linux distros, but available for any UNIX. Don't know about Windows. You can easily set it up to run out of cron and do a graceful apache HUP:

Here's a logrotate script I use - this is in /etc/logrotate.d, but you can run logrotate directly from a cron script at midnight, too:

<path to ias_oracle_home>/Apache/Apache/logs/error_log <path to ias_oracle_home>/Apache/Apache/logs/error_log_pls <path to ias_oracle_home>/Apache/Jserv/logs/mod_jserv.log {
   copytruncate
   compress
   size=1M
   rotate 9
   postrotate
su - applprod -c "/opt/oracle/prodcomn/admin/scripts/ prod_diana/adapcctl.sh status" if [ $? -ne 1 ]; then # Status of 1 indicates apache is already down and
# there is no need to HUP the process
su - applprod -c "<path to common_top>/admin/scripts/<context_name>/ adapcctl.sh graceful"
fi
   endscript
}

Mine is set up to rotate when the error_log, error_log_pls, and mod_jserv.log reach 1mb in size. It will truncate copy the old log to <log>.n, truncate the old log, then compress the copy. 9 copies will be kept.

You can, of course configure this however you like.

The key part is the graceful apache restart after the log rotation. Sometimes rotating the logs can wedge the apache daemon, so a graceful restart is nice.

Hope that helps a bit - logrotate is a great tool. I use it for alert logs, listener logs, apache logs, etc.
Chuck



On Oct 16, 2009, at 8:26 AM, kathy duret wrote:

I am using the rotatelog function for my Apache logs.

ErrorLog "|/u01/Apache/Apache/bin/rotatelogs
/u01/app/oracle/product/sso10g/Apache/Apache/logs/error_log.%Y%m%d 86400"

While this does rotate the logs every 24 hours with a datetime, I specifically need to have it run at midnight.

Yes, I have an SR open and yet I posted to Apache forums.

There is a transferlog function but I haven't been able to get this to work I thought if I could manually force a rotate, then I could just cron this to go at midnight.

Happy Friday.

K






Other related posts: