Restart Apache

2002-11-26 Thread Jeremy Schwartz
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

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.

This may seem OT for this list, but I figure if someone can either shed some
light on this or provide me a Perl example I'd be right on topic.

TIA
---
Jeremy SchwartzStarmark
Interactive Developer
[EMAIL PROTECTED]954-761-1600




Re: Restart Apache

2002-11-26 Thread gene

On Tuesday, November 26, 2002, at 11:55  AM, 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

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.


My first guess is that apachectl is not in the path for the script.
Try putting in the full path for apachectl.

If that still doesn't work, have you checked the error log for apache
to see if it's dying on startup??






[Solved] Re: Restart Apache

2002-11-26 Thread Jeremy Schwartz
That did it!

Thanks Gene and everyone who chimed in on this. It was the full path on
apachectl that was causing the issue.

This works great for anyone looking for an easy solution to roll your logs.

#!/bin/sh

mv /var/log/httpd/access_log /users/admin/logs/
/usr/sbin/apachectl restart

---
Jeremy SchwartzStarmark
Interactive Developer
[EMAIL PROTECTED]954-761-1600

 From: gene [EMAIL PROTECTED]
 Date: Tue, 26 Nov 2002 12:01:31 -0800
 To: Jeremy Schwartz [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: Re: Restart Apache
 
 
 On Tuesday, November 26, 2002, at 11:55  AM, 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
 
 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.
 
 
 My first guess is that apachectl is not in the path for the script.
 Try putting in the full path for apachectl.
 
 If that still doesn't work, have you checked the error log for apache
 to see if it's dying on startup??
 
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Restart Apache

2002-11-26 Thread Chris Devers
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. where
    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 . 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]



Re: Restart Apache

2002-11-26 Thread Dwalu Z. Khasu
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
=
=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.
=
=This may seem OT for this list, but I figure if someone can either shed some
=light on this or provide me a Perl example I'd be right on topic.
=
Jeremy,

At quick glance, I'd say qualify all commands, ie. use a fully qualified
path for all the commands in your script:

mv /var/log/httpd/access_log /users/admin/logs/ -- /bin/mv or /usr/bin/mv
apachectl restart -- path_to_apache/bin/apachectl restart

Also, the script is running so this doesn't seem to be a problem, however
you may run into problems later with the 'space' in the first line, so:

# /bin/sh -- should really look like #!/bin/sh


Hope this helps--

- Dwalu
..peace
--
I am an important person in this world -
Now is the most important time in my life -
My mistakes are my best teachers -
So I will be fearless.
- Student Creed