![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script for checking and reporting file sizes in a directory. | marconi | Shell Programming and Scripting | 1 | 04-03-2008 08:00 AM |
| Script to check and report database file sizes... | marconi | Shell Programming and Scripting | 2 | 04-02-2008 05:50 AM |
| Help on adding file sizes | llsmr777 | UNIX for Dummies Questions & Answers | 1 | 09-18-2007 02:58 PM |
| Script for file names/sizes | ssmiths001 | Shell Programming and Scripting | 2 | 05-09-2006 05:55 PM |
| compare file sizes | joli | Shell Programming and Scripting | 4 | 02-04-2005 06:52 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
syslog log file sizes
I am logging the messages from a router network and the log files are getting enormous is there any way to limit the size of the log file by either wrapping it or preferably creating a new one and renaiming the old.
Cheers mike |
|
|||||
|
For syslog, try this:
# cat $logfile | gzip -9 > $logfile.$date && > $logfile. This compresses the file as it rotates it, zeros it out and then keeps the same indoe open to any application that might have it open already. Make sure that this will do what you want though. For instance, if your log files are buffered, or the app reads in the log file for read/write, this might not work. Works fine for syslog: From: http://pcunix.com/Bofcusm/315.html |
|
||||
|
sorted thanks, here is the complete script
Code:
#!/bin/bash
#######################################################################
# #
# Script created mike smith (mike.smith@neosnetworks) #
# #
# Last edit 19/06/2003 Ver1 #
#######################################################################
# Check logfile is specified in command line
if [ $# -lt 1 ] ; then
echo
echo You need to specify the logfile to rotate i.e. /var/syslogs/riverstone
exit 0
fi
# Set Variables
LOGFILE="$1"
FileDate=`date +%d%m%Y`
OUTFILE=$LOGFILE.$FileDate.gz
#Rotate File
cat $LOGFILE | gzip -9 > $OUTFILE && > $LOGFILE
#
Code tags added for readability --- Perderabo Last edited by Perderabo; 06-19-2003 at 08:53 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|