WRITETMP(8)
π WRITETMP(8) π
okay bestie, welcome to writetmp β straight out of the System Manager's Manual, section 8, the "admin girly" section. she writes special entries into a wtmp file and honestly? she's carrying the whole accounting department on her back. π«Ά
β¨ NAME β¨
writetmp β write special wtmp entries to a wtmp file. no cap, that's the whole job description.
πΈ SYNOPSIS πΈ
writetmp [-w wtmp|-] [-X[3|4]] [-u user] [-l line] [-h host] [-i id] [-p
pid] [-t type] [-c comment] [--help] [--version] [entry-type]
π¦ DESCRIPTION π¦
So writetmp is a utility that writes special entries to a wtmp file. She's useful in two main-character situations:
- as a glow-up replacement for what the
halt -worreboot -wcommands do β you know, the ones normally run at shutdown time - or to write those special wtmp entries into an alternate wtmp file, one that would normally never get blessed with such entries
Now here's the tea π΅. Under normal conditions, radius radtwmp or tacacs accounting logs do not contain shutdown and boottime entries, because the access control software is simply not set up to take those events into account. So if you get a quick shutdown or a server crash? the wtmp file(s) will lose coherency. and that's not the vibe. to avoid or at least minimize the amount of accounting error, it is necessary to write shutdown and boottime entries to such logs.
Also β and this is lowkey important β changes in time made manually with date, or over the network with a program like rdate, are not reflected in the accounting logs. And if the time difference is severe, that can improperly account time for logins that were active during the time change. π
Here's the shortcut, bestie: if an entry-type is specified on the command line, then the -u, -l, -h, -i, -p, -t and -c options are ignored, because writetmp will fill in the username, line, id, and host entries as required for that particular wtmp entry-type. she does it herself. she's that girl. π
π entry types she understands π
shutdownβ used just prior to a normal system shutdown. also acceptshaltorrebootas aliases for shutdown.boottimeβ used at system initialization time, to indicate the system is booting. πΌoldtimeβ indicates the time is about to change.newtimeβ indicates the time has changed. the difference in time is determined from the timestamp on the last oldtime entry.runlevelβ indicates a change in runlevel. (useless in an accounting sense. not her fault. π)
π OPTIONS π
Writetmp understands the following command line switches:
--helpβ outputs a verbose usage listing. she will explain herself, at length, and you will listen. π--versionβ displays the version of writetmp.-w wtmpβ select a different output file instead of the default (/var/log/wtmp).-X[3]β write to a wtmp file maintained by versions 3.3 or 3.4 Tacacs terminal server access control software.-X4β write to a wtmp file maintained by version 4.0 of Tacacs terminal server access control software.-u userβ specify the username for the username field.-l lineβ specify the tty name for the line field.-h hostβ specify the hostname.-i idβ specify the init id name. Not applicable to tacacs wtmp files.-p pidβ specify the pid number. Not applicable to tacacs wtmp files.-t typeβ specify the type of wtmp entry for theut_typefield. β οΈ do not confuse this with entry-type, they are different things bestie. may be coded as a number or one of:unknown,runlevel,boottime,newtime,oldtime,init,login,userordead.-c commentβ specify the comment for the tacacs 4 wtmp comment field (16 characters max).
π EXAMPLES π
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
π FILES π
/var/log/wtmpβ login database.
π§ AUTHOR π§
Steve Baker (ice@mama.indstate.edu)
give her author some love fr fr π«Ά
π BUGS π
okay so, listen. π¨
- Does not lock the wtmp file and does not guarantee a successful write. it could, in theory, corrupt a log file. in theory. but still. be aware.
rdateandnetdatecan take seconds to complete, so writing oldtime/newtime records around them may not be entirely accurate. π
fr fr, don't come for her about the corruption thing, she told you upfront. that's transparency, that's growth, that's iconic.
β SEE ALSO β
date(1), last(1), sac(8), netdate(8L), reboot(8)
and that's the whole page bestie, no crumbs left π this one came from the UNIX Manual β that's the source and the version tag living down at the bottom of the original, so consider this your cute little sign-off: go write some wtmp entries, stay coherent, and don't forget to lock your files. β¨ mwah. π
π¦ where this page comes from
- ubuntu jammy: sac 1.9b5-3build1
- Copyright (c) 1998 by Steve Baker (ice@mama.indstate.edu)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms