39.6 lastcomm: What Commands Are Running and How Long Do They Take?When you're debugging a problem with a program, trying to figure out why your CPU usage bill is so high, or curious what commands someone (including yourself) is running, the lastcomm command on Berkeley-like UNIXes can help (if your computer has its process accounting system running, that is). Here's an example that lists the user lesleys : % The processes are listed in the order completed, most-recent first.
The lastcomm can do more. See its manual page. Here's a hint: on a busy system with lots of users and commands being logged, lastcomm is pretty slow. If you pipe the output or redirect it into a file, like this:
then the lastcomm output may be written to the file or pipe in big chunks instead of line-by-line. That can make it look as if nothing's happening. If you can tie up a terminal while lastcomm runs, there are two workarounds. If you're using a window system or terminal emulator with a "log to file" command, use it while lastcomm runs. Otherwise, to copy the output to a file, start script (51.5 ) and then run lastcomm : % A final word: lastcomm can't give information on commands that are built into the shell (1.10 ) . Those commands are counted as part of the shell's execution time; they'll be in an entry for csh , sh , etc. after the shell terminates. - |
|