1753481 Members
4539 Online
108794 Solutions
New Discussion юеВ

Re: wtmpx

 
DW1234
Occasional Advisor

wtmpx

Attempting to trim wtmpx. Any ideas? Thanks!
10 REPLIES 10
James R. Ferguson
Acclaimed Contributor

Re: wtmpx

Hi:

Define "trim". Do you want to truncate the whole file or save some portion?

Regards!

...JRF...
singh sanjeev
Trusted Contributor

Re: wtmpx

this command will not effect your system, but you will loss all the information of user who logged in your server before
Sanjeev Singh
DW1234
Occasional Advisor

Re: wtmpx

I would like to save some portion
James R. Ferguson
Acclaimed Contributor

Re: wtmpx

Hi (again):

To keep only some of the data you will need to do:

# /usr/sbin/acct/fwtmp < /var/adm/wtmps > /tmp/wtmps

...edit text and rebuild binary:

# /usr/sbin/acct/fwtmp -ic < /tmp/wtmps > /var/adm/wtmps

Regards!

...JRF...
singh sanjeev
Trusted Contributor

Re: wtmpx

You can use below script to trim it :

Triming a log file :

#! /bin/sh
# trimlog
filesize=`cat $1|wc -l`
trim=`expr $filesize - $2`
if [ $trim -gt 0 ]
then
sed "1,$trim d" $1 > /tmp/$1
mv /tmp/$1 $1
echo $1 trimmed by $trim lines
fi

sysntax :
# trimlog oracle_listener.log 10000
Sanjeev Singh
James R. Ferguson
Acclaimed Contributor

Re: wtmpx

Hi (again):

@ Singh: You can't trim the 'wtmp*' files using tools like 'sed'. They are binary files, not text files. Other than using tools that understand their structure (notably 'fwtmp') you would need to roll-you-own with something like Perl.

Regards!

...JRF...
singh sanjeev
Trusted Contributor

Re: wtmpx

thanks JRF...for valuable information.
Sanjeev Singh
DW1234
Occasional Advisor

Re: wtmpx

Thanks Everyone! Been a great help!
DW1234
Occasional Advisor

Re: wtmpx

Thanks Everyone!