SUMMARY : How to cut cleanly binary.errlog

From: Theis Jean-Marie 77-21 theis_at_pegase.cad.cea.fr <theis_at_pegase.cad.cea.fr>
Date: Mon, 20 Oct 1997 11:09:49 +0200

-- 
===========================================================
Theis Jean-Marie : l'indien du placard
Tels : 7721 7527 4695
mail adress : theis_at_drfc.cad.cea.fr
===========================================================
Je passe le plus clair de mon temps ą l'obscurcir.
				Boris Vian
===========================================================


 ..many thanks to all : I have been overflowed with many responses ..
 
I have not given back all responses see below the most typical .
 
 The question was :
 
> As the /var/adm/binary.errlog of my systems grows very fat I need to
> reduce their size , but I do not want to loose the last events by using
> "cp /dev/null binary.errlog" .
> "tail -1000 etc... " is neither good as the new file starts with a
> corrupted entry ( fortunately dia or uerf can deal with it ).
> Is there a clean way to do that ???
>
I forgot to precise that I wanted to keep the files in binary and not
translated via uerf so tha I can give them to "dia" later.



from Harald Klatte :

mv /var/adm/binary.errlog /var/adm/binary.errlog.old

and

kill -HUP [uid of binlogd-process]

to reset that process.

A new /var/adm/binary.errlog will be created.
Without resetting the logging process it will still write to the .old file .

greetings

Harald


-- 
+---+  Harald Klatte   
--------------------------------
From Guy Dallaire :
What we do here is: 
a) Stop the binary logger + system logger (their  pid's are in /var/run/)
b) Make a copy of the current binary.errlog and var/adm/messages, remove 
older compressed copie(s)
c) optionnaly compress it
d) cat /dev/null > binary.errlog + var/adm/messages
e) restart binary logger and syslog (/sbin/init.d/syslog) 
We do this every monday night, keeping three weeks of compressed logs. If 
we have to look at older logs, we uncompress them and use uerf -f option. 
If we need to go further back, we restore from a backup tape.
Hope this helps.
---------------------------------
From Randy Rodgers :
I recently wrote a script that is executed by cron at 4:30 AM on Monday
mornings that does the following:
* Stop syslog
* move binary error log file
* start new binary log file
* start syslog
I have included this script below.
I also have a cron entry that runs at 4:35 AM on Monday that removes the
saved log files over 31 days old.
============================================================================
=============
#!/bin/ksh
#
#                                                       *****************
#                                                       * savebinerrlog *
#                                                       *****************
#
# Script: savebinerrlog
# Written by: Randy Rodgers
# Created: 09/05/97
# Purpose: Save/initialize the /var/adm/binary.errlog file.
#===========================================================================
===============
# Modifications:
#    Date     Who                           Reason
# ---------- ------
-----------------------------------------------------------------------
#===========================================================================
===============
# Description:
#   The /var/adm/binary.errlog file continues to grow larger.  This script
will move the
#   file to /usr/local/logs/binerrlog/binary.errlog.yymmdd then initialize
a new file.
#===========================================================================
===============
#                                                       VARIABLE SECTION
#===========================================================================
===============
#                                                       Command Variables
#---------------------------------------------------------------------------
---------------
CAT="/sbin/cat"                                         # cat
DATE="/sbin/date"                                       # date
MV="/sbin/mv"                                           # mv
#---------------------------------------------------------------------------
---------------
#                                                       Script Variables
#---------------------------------------------------------------------------
---------------
SYSLOG="/sbin/init.d/syslog"                            # start/stop syslog
#---------------------------------------------------------------------------
---------------
#                                                       Date Variables
#---------------------------------------------------------------------------
---------------
CDATE="$($DATE +"%y%m%d")"                              # Current date in
yy/mm/dd format
#---------------------------------------------------------------------------
---------------
#                                                  Directory/File Variables
#---------------------------------------------------------------------------
---------------
BINERRLOG="/var/adm/binary.errlog"                      # Binary error log
file
BINLOGDIR="binerrlogs"                                  # Binary error log
file directory
BINLOGFILE="binary.errlog.$CDATE"                       # Binary error log
(saved)
LOCALLOGSDIR="/usr/local/logs"                          # Local logs
directory
NULL="/dev/null"                                        # null device file
#===========================================================================
===============
#                                                         MAIN SECTION
#===========================================================================
===============
$SYSLOG stop                                            # Stop the binary
error logger (syslog)
$MV $BINERRLOG $LOCALLOGSDIR/$BINLOGDIR/$BINLOGFILE     # Move binary error
log file
$CAT $NULL>$BINERRLOG                                   # Start new binary
error log file
$SYSLOG start                                           # Start the binary
error logger (syslog)
============================================================================
=============
I hope this helps.
----------------------------------------
From kurt carlson :
We have the following scheduled 3 time a year:
#!/bin/ksh
echo "/usr/local/sbin/new.errlog: create new date stamped binary.errlog"
#
#960430kc created: touch binary.errlog.YYMMDD and hard link binary.errlog
#==============================================================================
	STAMP=`date +%y%m%d`			# today's date as YYMMDD
	LOG_F=/var/adm/binary.errlog
if [	-e ${LOG_F}.${STAMP} ];	then
	echo	"${LOG_F}.${STAMP} already exists:
"
else
	set -x
	touch	${LOG_F}.${STAMP}		# create new
	chgrp	system	${LOG_F}.${STAMP}	# let system read
	ln -f	${LOG_F}.${STAMP} ${LOG_F}	# re-link it
	kill -HUP `cat /var/run/binlogd.pid`	# restart binlogd
fi
	ls -l	${LOG_F}*
---------------------------------------
From Thomas P. Blinn:
Move the file aside (e.g., mv /var/adm/binary.errlog /var/adm/binary.errlog.001)
and then send a SIGHUP signal to the binlogd process (as described in the
binlogd reference page:
  The binlogd daemon also creates the /var/run/binlogd.pid, if possible.  The
  file contains a line that specifies the binlogd daemon's process identifi-
  cation number.   Use this number to disable or reconfigure the binlogd
  daemon.  To disable the binlogd daemon, send the process a SIGTERM signal.
  For example:
       kill -TERM `cat /var/run/binlogd.pid`
  To reconfigure the binlogd daemon, send the process a SIGHUP signal to
  cause it to read the configuration file again.  For example:
       kill -HUP `cat /var/run/binlogd.pid`
)
Tom
 
-----------------------------------------
From Knut Hellebų
1. Stop syslog (/sbin/init.d/syslog stop)
2. Clean the errorlog the way you want (e.g 'cp /dev/null ...')
3. Start syslog
------------------------------------
Many thanks also to :
Stefan Albert 
Kemal
Gert Maaskant
....
Received on Mon Oct 20 1997 - 14:56:37 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:37 NZDT