WRITETMP(8) | System Manager's Manual | WRITETMP(8) |
writetmp - write special wtmp entries to a wtmp file.
writetmp [-w wtmp|-] [-X[3|4]] [-u user] [-l line] [-h host] [-i id] [-p pid] [-t type] [-c comment] [--help] [--version] [entry-type]
Writetmp is a utility to write special entries to a wtmp file. Useful as either a replacement for the functionality of the "halt -w" or "reboot -w" commands which are normally run at shutdown time or to write special wtmp entries to an alternate wtmp file to which such entries would normally not be written.
Under normal conditions radius radtwmp or tacacs accounting logs do not contain shutdown and boottime entries because the access control software is not setup to take into account these events. In the case of a quick shutdown or server crash, the wtmp file(s) will lose coherency. To avoid or minimize the amount of accounting error, it is necessary to write shutdown and boottime entries to such logs.
Also changes in time which are made manually with date or via the network with a program such as rdate are not reflected in the accounting logs, which, if the time difference is severe can improperly account time for logins active during the time change.
If an entry-type is specified on the command line, the -u, -l, -h, -i, -p, -t and -c options are ignored as writetmp will fill in the username, line, id, and host entries as required for that particular wtmp entry-type.
Writetmp understands the following entry types:
Writetmp understands the following command line switches:
Write a shutdown message to an alternate wtmp log:
writetmp -w /var/adm/xtmp shutdown
A shell script to update the time in an alternate wtmp file when netdate is run:
#!/bin/sh
writetmp -w /var/adm/xtmp oldtime
netdate clock.llnl.gov
writetmp -w /var/adm/xtmp newtime
Find out how often and for how long people run a specific program, such as pine:
#!/bin/sh
# /var/adm/cmdtmp must be globally writable.
cmdtmp=/var/adm/cmdtmp
writetmp -w $cmdtmp -u pine -l cmd$$ -h $USER -t user
/path/to/real-pine $*
writetmp -w $cmdtmp -l cmd$$ -t dead
/var/log/wtmp login database.
Steve Baker (ice@mama.indstate.edu)
Does not lock the wtmp file and does not guarantee a successful write. Could in theory corrupt a log file.
Rdate and netdate can take seconds to complete, so writing oldtime/newtime records around them may not be entirely accurate.
UNIX Manual |