forrie@morwyn.UUCP (Forrie Aldrich) (05/09/91)
I'm looking for a program that can be used to trim (regularly)
logfiles such as /usr/adm/sulog and /usr/spool/smail/log/logfile,
and the such that accumalte frequently ... yet retain the last
few entries while deleting the rest...
I've heard about a program like this somewhere, but haven't been
able to find it.
Thanks,
Forrie
--
--------------------=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--------------------
Forrest Aldrich, Jr.| ...uunet!eci!morwyn!forrie |forrie@morywn.UUCP
| ...uunet!eci!zinn!morwyn!forrie |
CREATIVE CONNECTIONS|...uunet!unhd!unhtel!morwyn!forrie |Graphic Illustration
------------------\-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-/------------------
\___ PO Box 1541 - Dover, NH 03820 ___/
bharat@computing-maths.cardiff.ac.uk (Bharat Mediratta) (05/09/91)
In article <100@morwyn.UUCP> forrie@morwyn.UUCP (Forrie Aldrich) writes: >I'm looking for a program that can be used to trim (regularly) >logfiles such as /usr/adm/sulog and /usr/spool/smail/log/logfile, >and the such that accumalte frequently ... yet retain the last >few entries while deleting the rest... > >I've heard about a program like this somewhere, but haven't been >able to find it. I use a shell script to trim my internal logfiles (.where, mail_log, etc.) and I find it pretty useful. Cheers, Bharat --- CUT HERE -- #!/bin/csh -f set name = $argv[1] set tmp = /tmp/$name set max = 200 # Max number of lines in log before it's trimmed set min = 80 # what the log's trimmed down to set size = `wc -l $name | awk '{print $1}'` if ("`expr $size \> $max`" == "1") then tail -$min < $name > $tmp if (-e $tmp) then if (`wc -l $tmp | awk '{print $1}'` == $min) then cp $tmp $name /bin/rm -f $tmp else echo "Error: Processed file incorrectly." endif else echo "Error: Couldn't create temporary file." endif endif -- CUT HERE -- -- | Bharat Mediratta | JANET: bharat@cm.cf.ac.uk | +--------------------+ UUNET: bharat%cm.cf.ac.uk%cunyvm.cuny.edu@uunet.uucp | |On a clear disk... | uk.co: bharat%cm.cf.ac.uk%cunyvm.cuny.edu%uunet.uucp@ukc| |you can seek forever| UUCP: ...!uunet!cunym.cuny.edu!cm.cf.ac.uk!bharat |
jpr@jpradley.jpr.com (Jean-Pierre Radley) (05/17/91)
In article <100@morwyn.UUCP> forrie@morwyn.UUCP (Forrie Aldrich) writes: >I'm looking for a program that can be used to trim (regularly) >logfiles such as /usr/adm/sulog and /usr/spool/smail/log/logfile, >and the such that accumalte frequently ... yet retain the last >few entries while deleting the rest... > >I've heard about a program like this somewhere, but haven't been >able to find it. I use 'prune', which came out on the net in 1985. It deals with ASCII files only, but will chop them using a list of files-newsizes in /etc/default/prune. The whole source code is barely 4K of ASCII, so I'll mail it to anyone who asks. Jean-Pierre Radley Unix in NYC jpr@jpr.com jpradley!jpr CIS: 72160,1341