/utmp, wtmp, utmpx and wtmpx may have become corrupt.
As the user root, create the following script to clear utmp,
wtmp, utmpx and wtmpx prior to shutdown:
----------------------cut here---------------------------------
#!/bin/sh
# /bin/clearutmp
#
# clear utmp, wtmp, utmpx and wtmpx on shutdown or bootup
#
> /etc/utmp
> /etc/wtmp
> /etc/utmpx
> /etc/wtmpx
----------------------cut here---------------------------------
Save the clearutmp script to /bin and run:
# chmod 700 /bin/clearutmp
The above script can be run manually prior to shutting the system
down, or you can add the following lines at the end of
/etc/bcheckrc to clear /etc/utmp, wtmp, utmpx and wtmpx during
system start-up.
As an example, add the following to the end of /etc/bcheckrc:
#
# Added to clear /etc/utmp, wtmp, utmpx and wtmpx on boot
#
> /etc/utmp
> /etc/wtmp
> /etc/utmpx
> /etc/wtmpx
Note: It is not recommended that /bin/clearutmp be run unless the
system is about to be brought down. The utmp and related files
contain valuable information about system state and start-up times;
clearing those files during run-time can cause unpredictable results.
The following relates to OpenServer only:
The /etc/auth/system/ttys file may be corrupt.
As the user root, create the following shell script to clear the
/etc/auth/system/ttys file:
------------------------------------cut here------------------------------------
#!/bin/sh
# /bin/clearttys
RC=0
mv /etc/auth/system/ttys /tmp/ttys.$$
touch /etc/auth/system/ttys
chown auth:auth /etc/auth/system/ttys
cd /tcb/bin
./ttyupd </dev/null >/dev/null 2>&1
RC=$?
if [ "$RC" -ne 0 ]; then
echo "*ERROR* Running ./ttyupd (RC=$RC)" > /tmp/clearttys.log
else
/tcb/bin/ale /etc/auth/system/ttys pttyupd </dev/null >/dev/null 2>&1
RC=$?
# Both 0 and 2 exit codes are success... exit 2 is used when there
# are no ttys to update
if [ "$RC" -ne 0 ] && [ "$RC" -ne 2 ]; then
echo "*ERROR* Running ./pttyupd (RC=$RC)" >> /tmp/clearttys.log
fi
fi
exit "$RC"
------------------------------------cut here------------------------------------
Save the clearttys script to /bin and run:
# chmod 700 /bin/clearttys
The script, clearttys, can be run while the system is in multiuser
mode when the "who" command displays users who are not logged in
or use crontab to set up cron to run clearttys at regular intervals.
NOTE:
To see where the user's have logged in from, ie. their IP address,
use the "finger" command.
The same command is also applicable to UnixWare7/Open UNIX 8 and
OpenLinux as the "who -xm" command is only applicable to OpenServer.
NOTE:
TROUBLESHOOTING:
- Seeing "Can't find utmp entry for ptty" errors and unable to log in.
The /etc/issue information is displayed on the screen but the login
prompt doesn't appear.
Clear down the /etc/utmp, utmpx, wtmp and wtmpx files in the same as
described above then reboot your server.
In addition, check that there are no additional network services that
might be conflicting, such as "bootp" or a service also using port 23.
SEE ALSO:
For information on the ttyupd command, which achieves the same
result as the script above, see:
Technical Article 100737 - "I want to know what the /etc/utmp and /etc/wtmp files
contain."
Technical Article 104588, "Rebuild ttys file from inittab including pseudo ttys
after crash."
Technical Article 105755, "How to use the cwtmp utility to clear stale entries
from utmp and related files."
cron(C), crontab(C), ttys(F), rc(ADM), bcheckrc(ADM), who(C), w(C),
last(C)
|