Manage wtmp Log Size In Aix
1. CONVERT WTMP FILE TO A TEXT FILE AND REMOVE UNWANTED ENTRIES.
Covert the wtmp file to readable ascii text file:
/usr/sbin/acct/fwtmp < /var/adm/wtmp > /tmp/wtmp.ascii.txt
We can calculate number of lines of wtmp.ascii.txt file;
# cat /tmp/wtmp.ascii.txt|wc -l
3010110
See... how big it is!
We can use text editor such as vi editor or other text editor to remove unwanted entry from this wtmp.ascii.txt file. However, if the file is too big, some text editor software is unable to open it.
As an option, we can keep only last 1,500,500 lines (it is my number, you can choose your number yourself);
tail -1500500 /tmp/wtmp.ascii.txt >> /tmp/wtmp.ascii2.txt
We might edit the smaller wtmp.ascii2.txt file using text editor.
2. CONVERT THE TEXT FILE BACK TO WTMP FORMAT AND COPY TO THE DEFAULT LOCATION
Use the trimmed file.
/usr/sbin/acct/fwtmp -ic < tmp/wtmp.ascii2.txt>/var/adm/wtmp
3. REMOVE TEMPORARY FILES (optional).
rm /tmp/wtmp.ascii.txt
rm /tmp/wtmp.ascii2.txt
4. WE CAN COMPRESS WTMP LOG
cp /var/adm/wtmp /tmp
compress /tmp/wtmp
or gzip -9 /tmp/wtmp
cp /tmp/wtmp.Z /var/adm/
cp /dev/null /var/adm/wtmp
Covert the wtmp file to readable ascii text file:
/usr/sbin/acct/fwtmp < /var/adm/wtmp > /tmp/wtmp.ascii.txt
We can calculate number of lines of wtmp.ascii.txt file;
# cat /tmp/wtmp.ascii.txt|wc -l
3010110
See... how big it is!
We can use text editor such as vi editor or other text editor to remove unwanted entry from this wtmp.ascii.txt file. However, if the file is too big, some text editor software is unable to open it.
As an option, we can keep only last 1,500,500 lines (it is my number, you can choose your number yourself);
tail -1500500 /tmp/wtmp.ascii.txt >> /tmp/wtmp.ascii2.txt
We might edit the smaller wtmp.ascii2.txt file using text editor.
2. CONVERT THE TEXT FILE BACK TO WTMP FORMAT AND COPY TO THE DEFAULT LOCATION
Use the trimmed file.
/usr/sbin/acct/fwtmp -ic < tmp/wtmp.ascii2.txt>
3. REMOVE TEMPORARY FILES (optional).
rm /tmp/wtmp.ascii.txt
rm /tmp/wtmp.ascii2.txt
4. WE CAN COMPRESS WTMP LOG
cp /var/adm/wtmp /tmp
compress /tmp/wtmp
or gzip -9 /tmp/wtmp
cp /tmp/wtmp.Z /var/adm/
cp /dev/null /var/adm/wtmp
Comments