Forum OpenACS Q&A: Response to servername-error.log

Collapse
Posted by Andrew Piskorski on
Oh, ns_logroll, how useful! Thanks Arjun, somehow I never knew about that. Duh. FYI, AOLserver will also roll the server log if you send it a SIGHUP, so my (probably inferior) solution was to write a little Bourne shell script to send a a SIGHUP, and schedule it from crontab.

E.g., the crontab entries:

# Roll the AOLserver error log once a week, 12 am every Saturday:
0 0 * * 6 /web/acs-util/nsd-roll-error-log.sh mysite-dev
0 0 * * 6 /web/acs-util/nsd-roll-error-log.sh mysite

And the shell script itself - (I think I regsub'd the one backslash properly for BBoard - we'll see):

#!/bin/sh
#
# nsd-roll-error-log.sh
#
# $Header: /home/cvsroot/acs-util/nsd-roll-error-log.sh,v 1.1 2002/01/03 17:30:04 andy Exp $
#
# Rolls the AOLserver error log by sending a SIGHUP to the AOLserver
# process.  Intended to be run from crontab on an e.g. nightly or
# weekly basis.
#
# by Andrew Piskorski <atp@piskorski.com>, 2002/01/03


# TODO: Hard-coding the AOLserver home directory here is not so good.
# Come up with a better, more centralized way:

NSD_HOME_DIR="/web/aol3"

CMDNAME=`basename $0`

# First parameter passed to this script MUST be the AOLserver server
# name, e.g. "parnassus-dev":

server_name="$1"

USAGE="Usage:  ${CMDNAME} AOLSERVER_SERVER_NAME  
Where:  AOLSERVER_SERVER_NAME is e.g. 'parnassus-dev'. "

if [ "$server_name" = "" ]
then
  echo ; echo "$USAGE" ; echo
  exit
fi

nspid_file="${NSD_HOME_DIR}/log/nspid.${server_name}"

if [ ! -r "$nspid_file" ]
then
  echo "ERROR:  The AOLserver nspid file '$nspid_file' is not readable!" 1>&2
  exit
fi

nsd_pid=`cat $nspid_file`

if [ ! "$nsd_pid" -gt 0 ]
then
  echo "ERROR:  '$nsd_pid' is not a valid AOLserver PID!" 1>&2
  exit
fi

# Note: For some reason, the 'kill -s HUP $pid" syntax for kill
# doesn't work, so use the numeric form instead (SIGHUP is signal 1):

kill -1 $nsd_pid
cmd_exit_status=$?

if [ ! $cmd_exit_status -eq 0 ]
then
  echo "ERROR:  Command 'kill -s HUP $nsd_pid' failed with error code '$cmd_exit_status'." 1>&2
fi