[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 4

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/dayacct. The runacct command also prepares summary files for the prdaily procedure to prepare the ASCII daily report, /var/adm/acct/sum/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/tacct. The tacct report is used by the monacct command to produce the monthly report, /var/adm/acct/fiscal.

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, refer to "Restarting runacct Procedures".

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/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, 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/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/tacct report file.
CMS Produces command summaries in the file /var/adm/acct/sum/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/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 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/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.

Security

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

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 
    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/accterr file. This command is only one of the accounting instructions normally given to the cron daemon. See "Setting Up an Accounting System" in AIX Version 4.3 System Management Guide: Operating System and Devices for more information on typical cron accounting entries.
  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/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/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/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/accterr file.

Files

/var/adm/wtmp Log in/log off history file.
/var/adm/pacct* Process accounting file.
/var/adm/acct/nite/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/* Command and total accounting summary files.
/var/adm/acct/nite/ptacct*.mmdd Concatenated version of pacct files.
/var/adm/acct/nite/active The runacct message file.
/var/adm/acct/nite/lock* Prevents simultaneous invocation of runacct.
/var/adm/acct/nite/lastdate Contains last date runacct was run.
/var/adm/acct/nite/statefile Contains current state to process.

Related Information

The acctcms command, acctcom command, acctcon1 or acctcon2 command, acctmerg command, acctprc1, acctprc2, or accton command, crontab command, fwtmp command.

The cron daemon.

The acct subroutine.

The acct file format, utmp, wtmp, failedlogin file format.

For more information about the Accounting System, the preparation of daily and monthly reports, and the accounting files, see the Accounting Overview in AIX Version 4.3 System Management Guide: Operating System and Devices.

Setting Up an Accounting System in AIX Version 4.3 System Management Guide: Operating System and Devices describes the steps you must take to establish an accounting system.

See the Accounting Commands in AIX Version 4.3 System Management Guide: Operating System and Devices for a list of accounting commands that can be run automatically or entered from the keyboard.


[ Previous | Next | Contents | Glossary | Home | Search ]