1848730 Members
2707 Online
104036 Solutions
New Discussion

btmps and wtmps files

 
SOLVED
Go to solution
Carles Viaplana
Valued Contributor

btmps and wtmps files

Hello,

wtmps and btmps are too much large. Can we initialize these files?

Thanks in advance for your help.
Regards,

Carles
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: btmps and wtmps files

> /var/adm/wtmp

- and -

> /var/adm/btmp

will do the job.


Pete

Pete
Peter Godron
Honored Contributor
mobidyc
Trusted Contributor
Solution

Re: btmps and wtmps files

Hello,

i've recently wrote a script for purging these files, it's here:

---<---
#!/bin/ksh

[ "$(uname -s)" = "HP-UX" ] && {
MAX_SIZE="1024000"
REST_LINES="10000"

for XTMP in /var/adm/wtmp /var/adm/btmp /etc/utmp
do
[ -f "$XTMP" ] || continue
SIZE=
SIZE=$(/bin/ls -l $XTMP |awk '{print $5}' 2>/dev/null)

if [ "$SIZE" -gt "$MAX_SIZE" ]
then
/usr/sbin/acct/fwtmp < ${XTMP} >/tmp/${XTMP##*/}.OLD
tail -n $REST_LINES /tmp/${XTMP##*/}.OLD |/usr/sbin/acct/fwtmp -ic > $XTMP
rm /tmp/${XTMP##*/}.OLD 2>/dev/null
fi
done
}
---<---

regards,
Cedrick Gaillard
Best regards, Cedrick Gaillard
Carles Viaplana
Valued Contributor

Re: btmps and wtmps files

Thanks to all for solutions you provided.

Regards,

Carles