On Tue, 26 Nov 2002, Jeremy Schwartz wrote:
> I am trying to rotate my Apache logs using Cron and the following shell
> script:
>
> # /bin/sh
>
> mv /var/log/httpd/access_log /users/admin/logs/
> apachectl restart
As noted, full paths might be a good idea. That or, this being a Perl list
[well, two Perl lists :], you could make a Perl script out of it. :) But,
continuing down the path that you're near the end of, have you looked at
rotatelogs?
% man rotatelogs
man: Formatting manual page...
rotatelogs(8) rotatelogs(8)
NAME
rotatelogs - rotate Apache logs without having to kill the
server
SYNOPSIS
rotatelogs logfile rotationtime [offset]
DESCRIPTION
rotatelogs is a simple program for use in conjunction with
Apache's piped logfile feature which can be used like
this:
TransferLog "| rotatelogs /path/to/logs/access_log
86400"
This creates the files /path/to/logs/access_log.nnnn where
nnnn is the system time at which the log nominally starts
(this time will always be a multiple of the rotation time,
so you can synchronize cron scripts with it). At the end
of each rotation time (here after 24 hours) a new log is
started.
OPTIONS
logfile
The path plus basename of the logfile. If logfile
includes any Otherwise, the suffix .nnnn is auto-
matically added and is the time at which the log-
file was created.
rotationtime
The rotation time in seconds.
offset The number of minutes offset from UTC. If omitted,
zero is assumed and UTC is used. For example, to
use local time in the zone UTC -5 hours, specify a
value of -300 for this argument.
SEE ALSO
httpd(8)
March 2001 1
% which rotatelogs
/usr/sbin/rotatelogs
It seems to be available with both 10.1 and 10.2, and maybe older versions
of OSX as well.
> This script is set to 755 and is being executed by the root crontab. The
> first line is executing correctly, the log file is moving out of
> /var/log/httpd/ to /users/admin/logs/ but apache is not restarting.
Another possiblity: you may need to run this with root priviliges, either
by prefixing that line or the whole script with 'sudo' (and using your
account password when prompted) or by placing this in root's crontab.
--
Chris Devers [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]