home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / nsfast / root.10 / usr / ns-home / httpd-80 / rotate / rotate
Encoding:
Text File  |  1998-08-19  |  733 b   |  35 lines

  1. #!/bin/sh
  2.  
  3. # Rotates server log files, without affecting users who may be
  4. # connected to the server.
  5.  
  6. # This can be run as a cron script
  7.  
  8. DATE=`date +%d%h-%I%p`
  9. ROOTDIR=`dirname $0`
  10.  
  11. # Add here any additional hardcoded logfiles you want rotated.
  12. LOGS='errors secure'
  13. CUSTLOGS=`grep flex-init $ROOTDIR/config/obj.conf \
  14.           | sed -e 's/\\\"//g' -e 's/Init //g' -e 's/\" /\"/g' \
  15.           | awk 'BEGIN { FS = "\""; }  \
  16.                        { n = 0; \
  17.                          while(n++ <= NF) if(index($n, "/") == 1) print $n; }'`
  18.  
  19. (cd $ROOTDIR/logs;
  20.  
  21.  for i in $LOGS; do
  22.    if [ -f $i ]; then
  23.      mv $i $i.$DATE
  24.    fi
  25.  done
  26.  
  27.  for j in $CUSTLOGS; do
  28.    if [ -f $j ]; then
  29.      mv $j $j.$DATE
  30.    fi
  31.  done
  32. )
  33.  
  34. $ROOTDIR/restart
  35.