Scripting: How do I process accounting file /var/account/pact?

The file /var/account/pacct can not be used directly as it does not store accounting data in clear text format. Each time a process terminates a record for this process is appended to the accounting file.

ADVERTISEMENTS

In order to use this file to generate customize report from perl or shell script you need to convert this file in text format. You need to use dump-acct command which print an acct/pacct file in human-readable format.

# dump-acct /var/account/pacct

All fields are separated by vertical line. Fields are: command, user time, system time, effective time, uid, gid, memory, io, time. To print username and command you can use awk command in pipe as follows:

# dump-acct /var/account/pacct | awk -F’|’ ‘{ print $1 ” = ” $5 }’

Please note that to print an utmp file in human-readable format use command dump-utmp as follows:

# dump-utmp /var/log/wtmp

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • Laxman Apr 10, 2012 @ 11:39

    Great command ….
    Many Thanks

  • jitendra Jun 6, 2012 @ 12:54

    In my X86 – the file size is too large can any one tell me how can i reduce the size…
    4.8 G pacct
    1.5 G pacct.1

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.