[RC5-PROXYPER] Trimming log-files... (fwd)

Dirk Kuypers dk at comnets.rwth-aachen.de
Mon Dec 8 09:31:30 EST 1997



> > Yes, I think normally I would have to send a HUP to the proxy before 
> > doing so, but because I started it by using 'nohup rc5proxy' it is immune 
> > now.
> 
> No. Its not because of the nohup, its because the proxy never closes/
> open's its stdout. Let me suggest you need to write a logger to catch 
> the proxy's stdout and invoke it something like this:
> 
> % rc5proxy |& logit &
> 
> Ok, I forgot exactly what the rc5 proxy name is this week. And my 
> syntax is csh not sh or bash. Pipe stdout and stderr to logger.
> 
> Its probably easiest to write logger in /bin/sh. Or perl if that's your
> thing. Logger simply copies its stdin to a file, meanwhile it has a
> signal catcher to service HUP signals. Then send your HUP to logger and
> let it close its current log file and open a new one.
> 
> #!/bin/sh
> # beware! this code appears to work but hasn't been smoke tested.
> # dmk 12/5/97
> 
> #echo $$ > ${HOME}/var/run/$0.PID
> echo $$ > $0.PID
> 
> rotate() {
> 	# this may be too extreme for a timestamp
>         DATE=`date +%y%m%d%H%M%S`
>         LOGNAME=${DATE}.log
>         echo "Log started at " $DATE >> ${LOGNAME}
> }
> 
> # set up our trap for -HUP, signal 1
> # execute our rotate proc on every HUP signal
> trap rotate 1
> 
> # initialize our LOGNAME variable and file for the first time.
> rotate
> 
> while read line
> do
>         echo ${line} >> $LOGNAME
> done
> 
> Suggest you mkdir ~/var/run and have your logger write its PID in that 
> directory to make it easier to kill -HUP. Then rather than have logger 
> check the time, use cron to "kill -HUP `cat var/run/logit.PID`"
> 
> The above code didn't work worth a $#^@! when it was named "logger". 
> Found out the hard way FreeBSD already had a "logger" and I was 
> writting to my /var/log/messages via syslogd.

solaris has one too;-),

thanks for this nice script. It seems to work;-).

Dirk

--
  Dirk Kuypers                  ComNets - RWTH Aachen
  Jülicher Strasse 206-208	dk at comnets.rwth-aachen.de
  52070 Aachen			Phone +49 (0) 241 961180 
  
                                 
       

--
To unsubcribe, send 'unsubscribe rc5-proxyper' to majordomo at llamas.net



More information about the proxyper mailing list