LASTCOMM(1) FreeBSD General Commands Manual LASTCOMM(1)


lastcommshow last commands executed


lastcomm [ -EScesu][ -f file][ +format][ command ...][ user ...][ terminal ...]


The lastcomm utility gives information on previously executed commands. With no arguments, lastcomm prints information about all the commands recorded during the current accounting file's lifetime.

The following options are available:

Print the time the process exited.
Print the time the process started.
Print the amount of cpu time used by the process.
Print the amount of elapsed time used by the process.
Print the amount of system time used by the process.
Print the amount of user time used by the process.
-f file
Read from file rather than the default /var/account/acct. If file is a single dash (‘-’) lastcomm reads accounting entries from the standard input.

An operand with a leading plus sign (‘+’) is followed a user-defined format string which specifies the format in which to display the process's start or exit date and time. The format string may contain any of the conversion specifications described in the strftime(3) manual page, as well as arbitrary text.

If no options are specified, -cS is assumed. If lastcomm is invoked with arguments, only accounting entries with a matching command name, user name, or terminal name are printed. For example:

lastcomm a.out root ttyd0

would produce a listing of all the executions of commands named a.out by user root on the terminal ttyd0.

For each process entry, the following are printed.

  • The name of the user who ran the process.
  • Flags, as accumulated by the accounting facilities in the system.
  • The command name under which the process was called.
  • The amount of CPU ( -c), wall ( -e), system ( -s), or user ( -u) time used by the process (in seconds).
  • The time the process started ( -S) or exited ( -E).

The flags are encoded as follows: ``S'' indicates the command was executed by the super-user, ``F'' indicates the command ran after a fork, but without a following exec(3), ``D'' indicates the command terminated with the generation of a core file, and ``X'' indicates the command was terminated with a signal.

By default, accounting entries are printed going backwards in time, starting from the time lastcomm was executed. However, if lastcomm reads entries from its standard input, then entries are printed in the order they are read.


default accounting file


The command
lastcomm -Ee
will print the exit time and elapsed time of each command logged in /var/account/acct, while
tail -f -c 0 /var/account/acct | lastcomm -f -
will print details of each terminating command.


The lastcomm command appeared in 3.0BSD.
May 17, 2012 FreeBSD