• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

Solaris : how to truncate the wtmpx file

By admin

Many a time, we observe that it takes too much time to login into the server. Most of the time the reason being, the wtmpx file is growing, filling up the /var partition (often part of the root partition). In extreme cases, it may even prevent the possibility of logging in, because utmpx entries cannot be made, and login asks the user to exec login from the lowest level shell. In such cases /var/adm/wtmpx needs to be truncated without causing problems.

Using logadm command

The most appropriate way to limit the size of /var/adm/wtmpx is using logadm. For example, to limit the size of logfile to 300MB and rotate the logfile if its greater than 300MB :

# logadm -C 4 -c -s 300m -w /var/adm/wtmpx

Here,

-C count     Delete the oldest versions until there are not more than count files left.
-p period    Rotate a  log  file  after  the  specified  time  period  (period) .
-c           Rotate the log file by copying it and truncating the original  logfile to zero length, rather than renaming the file.
-w entryname Write an entry into the config file (that is, /etc/logadm.conf) 
-s size      Rotate the log file only if its size is greater than or equal to size.
-z count     Compress old log files after all other commands have been executed.

As the -w option is used, we would also get an entry in the /etc/logadm.conf file as :

# tail -1 /etc/logadm.conf
wtmpx -C 4 -c -s 300m /var/adm/wtmpx

To run the rule we just created using logadm, use the -v option which will print the output in verbose mode.

# logadm -v
--lines omitted--
# processing logname: /var/adm/wtmpx
#     using default template: $file.$n
mkdir -p /var/adm # verify directory exists
# cp -fp /var/adm/wtmpx /var/adm/wtmpx.0 # rotate log file via copy (-c flag)
# cp -f /dev/null /var/adm/wtmpx # trucate log file (-c flag)
touch /var/adm/wtmpx
chown 4:4 /var/adm/wtmpx
chmod 644 /var/adm/wtmpx
#     recording rotation date Tue Feb 25 13:51:14 2014 for /var/adm/wtmpx
# writing changes to /var/logadm.conf

Verify the results :

# ls -l /var/adm/wtmpx*
-rw-r--r--   1 adm      adm            0 Dec 25 13:51 /var/adm/wtmpx
-rw-r--r--   1 adm      adm    362328000 Dec 25 12:54 /var/adm/wtmpx.0

zero-out the file

Another easiest way to trancate the wtmpx file is to zeo it out as :

# > /var/adm/wtmpx

Filed Under: Solaris

Some more articles you might also be interested in …

  1. How to set boot-device with luxadm command in Solaris
  2. Beginners Guide to Solaris 11 Network Administration
  3. How To Delete Files on a ZFS Filesystem that is 100% Full
  4. 12 iostat examples for Solaris performance troubleshooting
  5. How to Configure a Solaris 10 Jumpstart server and client [SPARC]
  6. Solaris beginners guide to NFS
  7. Oracle VM Server for SPARC (Ldoms) : How to Change Primary/Control Domain’s UUID
  8. How to log SSH login attempts to a file in Solaris
  9. How to install and configure sudo in solaris 10 (SPARC and x86/x64)
  10. Solaris : How to automate scp transfer (using passwordless ssh)

You May Also Like

Primary Sidebar

Recent Posts

  • Understanding “docker stats” Command Output
  • ‘docker images’ command error – “Permission Denied”
  • Docker Basics – Expose ports, port binding and docker link
  • How to split BCV and open oracle ASM database
  • How to change the interface name in CentOS/RHEL 8 using prefixdevname
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary