Technical article 105755

How to use the cwtmp utility to clear stale entries from utmp and related files.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5OpenServer 5.0.6OpenServer 5.0.7

Written · Last revised

Problem

who(C), finger(C), and other commands, show users as logged in when
they are not.

Cause

It is possible that /etc/utmp and related files have stale entries. Output from "who" and related commands is based on these files. The stale entries may be due to corruption in files that are read by utilities that update utmp, or to faulty third party software. In particular, the ttys file may have become corrupt. See other Technical Articles in the SCO Support Library, listed at the end of this article, for discussion and resolution of that problem, as well as alternatives for clearing /etc/utmp and related files.

Solution

Run the following diagnostic to determine if /etc/utmp is corrupt ("#" indicates the root command line prompt):

# kill -0 `who -u | awk '{print $7;}'`

Any output indicates a stale /etc/utmp entry associated with that process id. Consult other Technical Articles in this database, listed at the end of this article, for guidance in dealing with cases for which the diagnostic produces no output.

There is a public domain utility, called "cwtmp" (compress wtmp), for clearing stale entries from /etc/utmp and related files. It can be downloaded from:

ftp://ftp.armory.com/pub/scobins/cwtmp (binary)
ftp://ftp.armory.com/pub/source/cwtmp.tar.gz (compressed source)

Some browsers will not download the binary file correctly. If this is the case, connect to the following URL and press <Shift>+click on the "cwtmp" filename:

ftp://ftp.armory.com/pub/scobins
Once downloaded correctly, place cwtmp in root's search path, and
make it executable ("#" indicates the root command line prompt):
# chmod 700 cwtmp

You should first read the cwtmp instructions by running it with the -h flag:

# cwtmp -h

To clear the /etc/utmp file of stale entries, run cwtmp with the -U flag (U is uppercase):

# cwtmp -U
NOTE:     While cwtmp can be run in multi-user mode, there is a risk
          that a user logging into the system while cwtmp -U is being run
          can end up with a corrupt utmp/wtmp entry. For this reason
          we recommend that you either:

1) Avoid running cwtmp -U while users or logging into the system

or

2) Take the server into Single-User mode before running cwtmp

NOTE:     cwtmp is public domain software, and not part of any SCO-supported
          product.

See also

The manual pages for who(C), whodo(C), finger(C), awk(C), kill(C),
chmod(C), crontab(C).

For information on repairing a corrupt /etc/auth/system/ttys file, and for further discussion of utmp and related files:

TA105610, "I want to clear my system of users who are not logged
in."

TA104857, "Log in and get "no utmp entry. You must log in from lowest level -sh""

TA104588, "Rebuild ttys file from inittab including pseudo ttys after crash."

For cases in which the diagnostic in the "SOLUTION" section produces no output:

TA107691, "Configure telnetd to close connection when client connection no longer exists."

TA107693, "Configure rlogind to close connection when client connection no longer exists."

From the Xinuos technical article database, record 105755. Reproduced with permission. The original is at www.sco.com/ta/105755, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.