Operating System - HP-UX
1843936 Members
1703 Online
110226 Solutions
New Discussion

how to empty/reduce /var/adm/wtmp

 
Ho_5
Advisor

how to empty/reduce /var/adm/wtmp

Hi all,

I want to reduce the size of wtmp file. can somebody tell me how to recude it??
I want the file wtmp keep only the last 4 week login/session. So I need a script to put in the crontab.

Please tell me how to do that??

Thanks.

Regards,

John
4 REPLIES 4
Steve Steel
Honored Contributor

Re: how to empty/reduce /var/adm/wtmp

Hi


Here is utmp


/usr/lib/acct/fwtmp /tmp/utmp.ascii
vi /tmp/utmp.ascii
/usr/lib/acct/fwtmp -ic /etc/utmp

see man fwtmp and you will see

fwtmp(1M) fwtmp(1M)

NAME
fwtmp, wtmpfix - manipulate connect accounting records


With the command and a little experimentation you can do anything.


steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Balaji N
Honored Contributor

Re: how to empty/reduce /var/adm/wtmp

hi,

never tried this myself. check it out on a test box.

++++++++++
File utmp contains a record of all users logged onto the system. File
btmp contains bad login entries for each invalid logon attempt. File
wtmp contains a record of all logins and logouts.

Note that wtmp and btmp tend to grow without bound, and should be
checked regularly. Information that is no longer useful should be
removed periodically to prevent it from becoming too large. Also note
that wtmp and btmp are not created by the programs that maintain them.
Thus, if these files are removed, record-keeping is turned off.
++++++++++++++

from the man page i assume that, u can just delete the wtmp and btmp files and just touch it so that it can be used again.

or just
> /var/adm/wtmp.


hth
-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Sritharan
Valued Contributor

Re: how to empty/reduce /var/adm/wtmp

Hi,

I agreed with Balaji suggestion , the wtmp and utmp will grow tremendously if there are lot of logging. So the best way is to empty the files by

# > var/adm/wtmp or
# cat /dev/null > /var/adm/wtmp

or you can also use SAM to trim the log files
go to

SAM > Routine Tasks > System Log Files

from here you can trim the log files that you wanted to trim ; you can trim it to zero or the recommended size.

Thanks & Regards
Sri
Known is a drop...unknown is an ocean -> quote from a movie
David_246
Trusted Contributor

Re: how to empty/reduce /var/adm/wtmp

Hi John,

Tried to write you a perl script, but unfortunetly I could make it work the way you want.

The only thing I can think of is :

last -R -50 >/var/adm/wtmp.txt && >/var/adm/wtmp

This makes last display the last 50 lines inclusive hostnames display in the txt-file and afterwards wtmp will be emptied.

Hope this helps a little.


John, don't forget to give the people who helped you previous points for their answers.
Let's not be Dutch :) Be kind.
Oftwel gewoon even meehelpen.

Regs David
@yourservice