LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices


Reply
  Search this Thread
Old 07-15-2004, 09:13 AM   #1
Risc91
Member
 
Registered: Jan 2002
Location: Macomb, MI
Distribution: Ubuntu|Red Hat ES|AIX
Posts: 161

Rep: Reputation: 30
cleaning up /var/adm/wtmp


I have a box that had accounting enabled, but was forgotten about by a previous admin and as a result has a rather large wtmp file. Does anyone know of a perl script (or other) that will allow me to clean this file up?

I have found one, but it doesn't seem to be using the same format wtmp file. It doesn't account for all the fields in the wtmp file on the aix boxes.

I do not want to annihilate the whole file using cp /dev/null.

TIA
 
Old 07-15-2004, 04:07 PM   #2
zorba4
Member
 
Registered: Feb 2004
Location: Paris
Posts: 398

Rep: Reputation: 31
Just for fun, I would
1) backup wtmp, just in case : mv wtmp wtmp.first
2) tail -100 wtmp.first >wtmp.
3) if this did the job
then
thanks Zorba
else
sorry
 
Old 07-16-2004, 01:43 PM   #3
mpdavig
Member
 
Registered: May 2004
Location: Boston, MA
Distribution: Fedora
Posts: 30

Rep: Reputation: 19
I would install logrotate 3.6.8 or above and rotate the file once a week. It is common to most Linux distributions and compiles nicely on AIX.

If interested I have a binary and source AIX rpm I can send you.
 
Old 07-17-2004, 01:41 AM   #4
iainr
Member
 
Registered: Nov 2002
Location: England
Distribution: Ubuntu 9.04
Posts: 631

Rep: Reputation: 30
Although it doesn't affect wtmp, AIX has log rotation built in for syslog - you just specify in /etc/syslog.conf

Code:
[rotate [size <size> k|m] [files <files>] [time <time> h|d|w|m|y] [compress] [
archive <archive>]] is:
#       If <destination> is a regular file and the word "rotate" is
#       is specified, then the <destination> is limited by either
#       <size> or <time>, or both <size> and <time>. The <size> causes
#       the <destination> to be limited to <size>, with <files> files
#       kept in the rotation. The backup filenames are created by
#       appending a period and a number to <destination>, starting with
#       ".0". The <time> causes the <destination> to be rotated after
#       <time>. If <time> is specified, the backup filenames are created
#       by appending the date and time to <destination>, in the format
#       YYYYmmmdd:HH:MM:SS where:
#       YYYY = year
#       mmm  = name of the month
#       dd   = day
#       HH   = hour
#       MM   = minutes
#       SS   = seconds
#       If both <size> and <time> is specified, and the <size> causes
#       the log to rotate, then the backup filenames will be created
#       by appending both the date and time and a period and a number to
#       <destination>.
#       The minimum size that can be specified is 10k, the minimum
#       number of files that can be specified is 2. The default
#       size is 1m (meg) and the default for <files> is unlimited.
#       Therefore, if only "rotate" is specified, the log will be
#       rotated with <size> = 1m.
#       The compress option means that rotated log files that are not
#       in use will be compressed.
#       The archive option will save rotated log files that are not
#       in use to <archive>.
#       The default is not to rotate log files.
# Example : 
#  *.debug              /tmp/syslog.out     rotate size 100k files 4
 
Old 07-19-2004, 03:51 PM   #5
screwloose
LQ Newbie
 
Registered: May 2004
Posts: 23

Rep: Reputation: 15
#!/usr/bin/perl
truncate("/var/adm/wtmp",1000)

**Note: 1000 is an arbitrary number and truncates the file to N bytes.
 
Old 08-23-2004, 09:52 AM   #6
Yegolev
LQ Newbie
 
Registered: Aug 2004
Location: The ATL
Distribution: AIX 4.3/5.1/5.2
Posts: 6

Rep: Reputation: 0
#!/bin/ksh
# the IBM-approved method, more or less
# keep 10000 lines by default
let keep=${1:-10000}
/usr/sbin/acct/fwtmp < /var/adm/wtmp > /tmp/out
tail -n $keep /tmp/out > /tmp/trunc
/usr/sbin/acct/fwtmp -ic < /tmp/trunc > /var/adm/wtmp
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/var/log/wtmp mrant Linux - Security 4 07-14-2013 08:41 PM
/var/log/wtmp ??? fatrandy13 Linux - Software 3 12-13-2004 09:07 AM
Moving /var/adm and /var/lib - why does it hurt? J_Szucs Linux - General 1 09-15-2004 06:46 PM
/var/log/wtmp praveenv Linux - Newbie 5 08-23-2004 02:48 PM
/var/adm/utmpx hacked?!? Mike_the_Man Solaris / OpenSolaris 1 06-11-2004 07:25 AM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 04:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration