runacct Command

Purpose

Runs daily accounting.

Syntax

/usr/sbin/acct/runacctmmdd State ] ]

Description

The runacct command is the main daily accounting shell procedure. Normally initiated by the cron daemon, the runacct command processes connect, fee, disk, queuing system (printer), and process accounting data files for the current day to produce the binary daily report, /var/adm/acct/nite(x)/dayacct. The runacct command also prepares summary files for the prdaily procedure to prepare the ASCII daily report, /var/adm/acct/sum(x)/rprtmmdd, or for billing purposes.

The acctmerg command adds the dayacct report to the cumulative summary report for the accounting period, /var/adm/acct/sum(x)/tacct. The tacct report is used by the monacct command to produce the monthly report, /var/adm/acct/fiscal(x).

This command has two parameters that must be entered from the keyboard should you need to restart the runacct procedure. The date parameter, mmdd, enables you to specify the day and month for which you want to rerun the accounting. The State parameter enables a user with administrative authority to restart the runacct procedure at any of its states. For more information on restarting runacct procedures and on recovering from failures.

The runacct command protects active accounting files and summary files in the event of run-time errors, and records its progress by writing descriptive messages into the /var/adm/acct/nite(x)/active file. When the runacct procedure encounters an error, it sends mail to users root and adm, and exits.

The runacct procedure also creates two temporary files, lock and lock1, in the directory /var/adm/acct/nite(x), which it uses to prevent two simultaneous calls to the runacct procedure. It uses the lastdate file (in the same directory) to prevent more than one invocation per day.

The runacct command breaks its processing into separate, restartable states. As it completes each state, it writes the name of the next state in the /var/adm/acct/nite(x)/state file. The runacct procedure processes the various states in the following order:

State Actions
SETUP Moves the active accounting files to working files and restarts the active files.
WTMPFIX Verifies the integrity of the wtmp file, correcting date changes if necessary.
CONNECT1 Calls the acctcon1 command to produce connect session records.
CONNECT2 Converts connect session records into total accounting records (tacct.h format).
PROCESS Converts process accounting records into total accounting records (tacct.h format).
MERGE Merges the connect and process total accounting records.
FEES Converts the output of the chargefee command into total accounting records (tacct.h format) and merges them with the connect and process total accounting records.
DISK Merges disk accounting records with connect, process, and fee total accounting records.
QUEUEACCT Sorts the queue (printer) accounting records, converts them into total accounting records (tacct.h format), and merges them with other total accounting records.
MERGETACCT Merges the daily total accounting records in the daytacct report file with the summary total accounting records in the /var/adm/acct/sum(x)/tacct report file.
CMS Produces command summaries in the file /var/adm/acct/sum(x)/cms.
USEREXIT If the /var/adm/siteacct shell file exists, calls it at this point to perform site-dependent processing.
CLEANUP Deletes temporary files and exits.

Restarting runacct Procedures

To restart the runacct command after a failure, first check the /var/adm/acct/nite(x)/active file for diagnostic messages, then fix any damaged data files, such as pacct or wtmp. Remove the lock files and lastdate file (all in the /var/adm/acct/nite(x) directory), before restarting the runacct command. You must specify the mmdd parameter if you are restarting the runacct command. It specifies the month and day for which the runacct command is to rerun the accounting. The runacct procedure determines the entry point for processing by reading the /var/adm/acct/nite(x)/statefile file. To override this default action, specify the desired state on the runacct command line.

It is not usually a good idea to restart the runacct command in the SETUP state. Instead, perform the setup actions manually and restart accounting with the WTMPFIX state, as follows:

/usr/lib/acct/runacct mmdd WTMPFIX

If the runacct command fails in the PROCESS state, remove the last ptacct file, because it will be incomplete.

Flags

Item Description
-X Processes all available characters for each user name instead of truncating to the first 8 characters. The -X flag will also cause the runacct command and all commands it calls to use the /var/adm/acct/sumx and /var/adm/acct/nitex directories instead of the /var/adm/acct/sum and /var/adm/acct/nite directories.

Security

Access Control: This command should grant execute (x) access only to members of the adm group.

Attention RBAC users and Trusted AIX® users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Examples

  1. To start daily accounting procedures for system resources, add the following command line to a crontab file so the runacct command will be run automatically by the cron daemon:
    0 4 * * 1-6 /usr/sbin/acct/runacct 2> \
    /var/adm/acct/nite/accterr 
    To start daily accounting procedures with long user name support add the following line to the crontab file:
    0 4 * * 1-6 /usr/sbin/acct/runacct -X 2> \
    /var/adm/acct/nitex/accterr 
    This example shows the instructions that the cron daemon will read and act upon. The runacct command will run at 4 a.m. (04) every Monday through Saturday (1-6) and write all standard error output (2>) to the /var/adm/acct/nite(x)/accterr file. This command is only one of the accounting instructions normally given to the cron daemon.
  2. To start daily accounting procedures for system resources from the command line (start the runacct command), enter the following:
    nohup /usr/sbin/acct/runacct 2> \
    /var/adm/acct/nite/accterr &
    Although it is preferable to have the cron daemon start the runacct procedure automatically (see example 1), you can give the command from the keyboard. The runacct command will run in the background (&), ignoring all INTERRUPT and QUIT signals (the nohup command), and write all standard error output (2>) to the /var/adm/acct/nite/accterr file.
  3. To restart the system accounting procedures for a specific date, enter a command similar to the following:
    nohup /usr/sbin/acct/runacct 0601 2>> \
    /var/adm/acct/nite/accterr & 
    This example restarts runacct for the day of June 1 (0601). The runacct command reads the file /var/adm/acct/nite(x)/statefile to find out the state with which to begin. The runacct command will run in the background (& ), ignoring all INTERRUPT and QUIT signals (nohup). Standard error output (2) is added to the end (>>) of the /var/adm/acct/nite(x)/accterr file.
  4. To restart the system accounting procedures for a particular date at a specific state, enter a command similar to the following:
    nohup /usr/sbin/acct/runacct 0601 MERGE 2>> \
     /var/adm/acct/nite(x)/accterr &
    This example restarts the runacct command for the day of June 1 (0601), starting with the MERGE state. The runacct command will run in the background (&), ignoring all INTERRUPT and QUIT signals (the nohup command). Standard error output (2) is added to the end (>>) of the /var/adm/acct/nite(x)/accterr file.

Files

Item Description
/var/adm/wtmp Log in/log off history file.
/var/adm/pacct* Process accounting file.
/var/adm/acct/nite(x)/daytacct Disk usage accounting file.
/var/adm/qacct Active queue accounting file.
/var/adm/fee Record of fees charged to users.
/var/adm/acct/sum(x)/* Command and total accounting summary files.
/var/adm/acct/nite(x)/ptacct*.mmdd Concatenated version of pacct files.
/var/adm/acct/nite(x)/active The runacct message file.
/var/adm/acct/nite(x)/lock* Prevents simultaneous invocation of runacct.
/var/adm/acct/nite(x)/lastdate Contains last date runacct was run.
/var/adm/acct/nite(x)/statefile Contains current state to process.