Managing process accounting on Linux

Process accounting is a method of recording and summarizing commands and processes. It’s an option on Linux systems, but you have to enable it and use a particular command to view the details collected. This post covers the commands involved and offers some suggestions on making the views even more […]

Process accounting is a method of recording and summarizing commands and processes. It’s an option on Linux systems, but you have to enable it and use a particular command to view the details collected. This post covers the commands involved and offers some suggestions on making the views even more useful.

To start, understand that process accounting is different than what you see when running the ps command. It shows details on commands that have completed –- not those that are currently running. It also shows a lot more details than you would see by looking at your users’ command history files and keeps all the collected data in a single file on the system.

If you want to turn on the processing accounting, you have to use a command like this:

$ sudo /usr/sbin/accton on
Turning on process accounting, file set to the default '/var/log/account/pacct'.

On this system, the file /var/log/account/pacct is the file in which the data will be saved. This file is not a plain text file, so don’t try viewing it with more or tail commands. Instead, use the dump-acct command to view it as shown in the example below. Anticipate a very wide and lengthy display that will wrap around in a normal terminal window unless you widen it considerably or pipe output to the tail command.

$ sudo dump-acct /var/log/account/pacct | tail
grotty          |v3|     0.00|     0.00|     2.00|  1000|  1000| 12000.00|     0.00|  321103|  321101|     |       0|pts/1   |Fri Aug 14 13:26:07 2020
groff           |v3|     0.00|     0.00|     2.00|  1000|  1000|  6096.00|     0.00|  321101|  321095|     |       0|pts/1   |Fri Aug 14 13:26:07 2020
nroff           |v3|     0.00|     0.00|     4.00|  1000|  1000|  2608.00|     0.00|  321095|  321087|     |       0|pts/1   |Fri Aug 14 13:26:07 2020
man             |v3|     0.00|     0.00|     4.00|  1000|  1000| 10160.00|     0.00|  321096|  321087| F   |       0|pts/1   |Fri Aug 14 13:26:07 2020
pager           |v3|     0.00|     0.00|  2018.00|  1000|  1000|  8440.00|     0.00|  321097|  321087|     |       0|pts/1   |Fri Aug 14 13:26:07 2020
man             |v3|     2.00|     0.00|  2021.00|  1000|  1000| 10160.00|     0.00|  321087|  318116|     |       0|pts/1   |Fri Aug 14 13:26:07 2020
clear           |v3|     0.00|     0.00|     0.00|  1000|  1000|  2692.00|     0.00|  321104|  318116|     |       0|pts/1   |Fri Aug 14 13:26:30 2020
dump-acct       |v3|     2.00|     0.00|     2.00|  1000|  1000|  4252.00|     0.00|  321105|  318116|     |       0|pts/1   |Fri Aug 14 13:26:35 2020
tail            |v3|     0.00|     0.00|     2.00|  1000|  1000|  8116.00|     0.00|  321106|  318116|     |       0|pts/1   |Fri Aug 14 13:26:35 2020
clear           |v3|     0.00|     0.00|     0.00|  1000|  1000|  2692.00|     0.00|  321107|  318116|     |       0|pts/1   |Fri Aug 14 13:26:45 2020

Don’t be surprised if some of the processes shown are unfamiliar. Some may have been run by commands that you ran, rather than by you directly (e.g., groff and grotty in the output above). Many are system processes that are independent of user activity.

To better understand what you’re looking at, you may want to add column headings as I have done with these commands:

Copyright © 2020 IDG Communications, Inc.

Next Post

Focus on snap poll as Suga's continuity policy gives market firm footing

Financial markets in Japan are expected to find a firm footing following Prime Minister Yoshihide Suga’s pledge to continue with his predecessor Shinzo Abe’s economic policies to bring the coronavirus-stricken economy back onto a growth track. Market participants are closely watching whether the new prime minister will dissolve the Lower […]