#!/bin/sh # An adaptation of /var/adm/newsyslog that does multiple files named # on the command line. # # William LeFebvre, Group sys Consulting # ARCHIVE="OLD" if [ $# -lt 2 ]; then echo "usage: newlog dir name" exit 1 fi # # calculate suffix for current log files suffix=`date +%y%m%d` # # move to specified log directory cd $1 shift # # iterate thru each named log file while [ x$1 != x ]; do # move the existing log in to the archive mv -f $1 $ARCHIVE/$1.$suffix # create a new log file cp /dev/null $1 chmod 640 $1 shift done # # tickle syslog to get it to use the new log files kill -1 `cat /etc/syslog.pid` # # wait for syslog to switch over sleep 5 # # now compress the freshly archived logs # (we don't do this sooner to leave a place for syslog to continue to # log messages while we are shuffling files around) compress $ARCHIVE/*.$suffix