Index Index for
Section 8
Index Alphabetical
listing for R
Bottom of page Bottom of
page

runacct(8)

NAME

runacct - Runs daily accounting

SYNOPSIS

/usr/sbin/acct/runacct [mmdd] [state...]

OPERANDS

mmdd Specifies the month and day for which you want to rerun the accounting shell procedure. state Used to restart the runacct shell procedure from any of its thirteen states. The thirteen restartable states, in order, are: SETUP, WTMPFIX, CONNECT1, CONNECT2, PROCESS, MERGE, FEES, DISK, QUEUEACCT, MERGETACCT, CMS, USEREXIT, and CLEANUP. These states are described under The runacct Shell Procedure Restartable States heading in the DESCRIPTION section. Recovery from a run failure and the runacct shell procedure restart is described under the Restarting the runacct Shell Process heading in the DESCRIPTION section.

DESCRIPTION

The runacct command is the daily accounting shell procedure. This shell procedure is normally invoked from the cron daemon to process connection, fee, disk usage, queuing (printer), and process accounting database files for the current day. The runacct shell procedure produces a /var/adm/acct/nite/dayacct binary daily accounting file and also produces summary files, which the prdaily shell procedure uses to generate ASCII daily file /var/adm/acct/sum/rprtmmdd or to generate files used for billing for the use of various system resources. The /var/adm/acct/nite/dayacct binary daily accounting file is used by the acctmerg command. The acctmerg command adds records from the dayacct file to the /var/adm/acct/sumtacct file. The /var/adm/acct/sumtacct file is a cumulative summary of system resources used during the accounting period. The sumtacct file is used by the monacct command to produce the monthly accounting summary file, /var/adm/acct/fiscal. The runacct command has two operands that you may enter from the keyboard whenever you must restart the runacct shell procedure. The date operand, mmdd, is used to specify the day and month for which you want to rerun the accounting shell procedure. The state operand is used to restart the runacct shell procedure from any of its thirteen states. Recovery from a run failure and the runacct shell procedure restart is described under the Restarting Runacct heading on the next page. The runacct command protects active accounting and summary files whenever a run-time error occurs. During execution, the state-to-state progress of the runacct shell process is recorded by writing descriptive messages to the /var/adm/acct/nite/active file. Whenever the runacct shell process detects a run-time error, a mail message is sent to the superuser (root) and to the user named adm when environment variable MAILCOM is set to mail root adm. After writing the mail message the runacct shell procedure aborts. The runacct shell procedure also creates the temporary file named lock in subdirectory /var/adm/acct/nite. This file is used to prevent simultaneous calls to the runacct shell procedure. The runacct shell procedure also uses the lastdate file, in the same subdirectory, to prevent more than one invocation of the runacct command per day. The runacct Shell Procedure Restartable States The runacct shell procedure is processed in thirteen separate restartable states. When the runacct process completes each state, the name of the next state to undergo execution is written to the /var/adm/acct/nite/statefile file. The runacct procedure processes the various states named in the leftmost column below, in the order given. SETUP Moves the active accounting files to working files and restarts the active files. WTMPFIX Verifies the integrity of the /var/adm/wtmp file and corrects date changes when necessary. CONNECT1 Calls the acctcon1 command to write connect session records. CONNECT2 Converts connect session records from the /var/adm/wtmp file to total accounting records in total format defined by tacct structure members in the private tacct.h header file. PROCESS Converts process accounting records from the /var/adm/pacct* file(s) into total accounting records (see CONNECT2 above). MERGE Merges the connect and process total accounting records. FEES Converts the output obtained with the chargefee command into total accounting records (see CONNECT2 above) and merges them with other total accounting records. DISK Merges disk accounting records with connect, process, and fee total accounting records. QUEUEACCT Sorts queue (printer) accounting records, converts them into total accounting records (see CONNECT2 above), and merges them with other total accounting records. MERGETACCT Merges the daily total accounting records in the /var/adm/acct/nite/dayacct file with summary total accounting records in the /var/adm/acct/sum/tacct file. CMS Produces command summaries in the file /var/adm/acct/sum/cms. USEREXIT When the shell procedure /var/adm/siteacct exists, and the runacct shell procedure enters this state, the /var/adm/siteacct is called to perform site-dependent account record processing. CLEANUP Deletes all temporary files and exits. Restarting the runacct Shell Process To restart the runacct shell process after it fails, do the following: 1. Check the /var/adm/acct/nite/active file for diagnostic messages. 2. Repair records in any damaged database files, such as /var/adm/pacct or /var/adm/wtmp. 3. Remove the /var/adm/acct/nite/lock and /var/adm/acct/nite/lastdate files. 4. Before restarting the runacct shell procedure, you must specify the mmdd operand of the runacct command. This operand specifies the month and day for which the runacct command is to rerun the accounting shell process. The runacct shell procedure determines the entry point for processing by reading the /var/adm/acct/nite/statefile file. To override this default action, specify a state listed above on the runacct command line. It is not a good idea to restart the runacct command in the SETUP state. Instead, perform set-up actions manually and restart accounting in the WTMPFIX state by entering the following command: runacct mmdd WTMPFIX Should the runacct process fail during its PROCESS state, remove the last /var/adm/acct/nite/ptacct*.mmdd file before restarting the runacct shell process because the file does not complete until the next state is entered.

EXAMPLES

1. To start daily accounting procedures for the use of various system resources, add the following command line to a crontabs file so that the runacct shell procedure is automatically called 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 reads and then executes. The runacct shell procedure runs at 4:00 a.m. (0 4) every Monday through Saturday (1-6) and redirects errors from the standard error output (2 >) to the /var/adm/acct/nite/accterr file. This command typifies accounting instructions normally passed to the cron daemon from the runacct shell procedure. (See the System Administration manual.) 2. To start daily accounting procedures for system resources from the command line (start the runacct command), enter: 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 the first example), you may enter the command from the keyboard. The runacct command will run in the background, ignoring all INTERRUPT and QUIT signals (nohup), 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& In this example, the runacct command is executed on the first day of June (0601). The runacct process reads the /var/adm/acct/nite/statefile file to find the state from which to start. The runacct process runs in the background and ignores all INTERRUPT and QUIT signals (nohup). The standard error output (2) is appended (>>) to the end of the file named /var/adm/acct/nite/accterr.

FILES

/usr/sbin/acct/runacct Specifies the command path /var/adm/wtmp The active login/logout database file. /var/adm/pacct The active process accounting database file. /var/adm/acct/nite/daytacct The active disk-usage accounting database file. /var/adm/qacct The active queue (printer) accounting file. /var/adm/fee The file containing records of fees charged to users. /var/adm/acct/sum/* The command and total accounting summary files. /var/adm/acct/nite/ptacct*.mmdd The concatenated version of the pacct files. /var/adm/acct/nite/active The runacct error message file. /var/adm/acct/nite/lock Prevents more than one invocation of the runacct shell procedure. /var/adm/acct/nite/lastdate Contains the last date the runacct shell procedure was run. /var/adm/acct/nite/statefile Contains the next state to process. /var/adm/siteacct A shell procedure containing site-dependent accounting commands. /usr/include/sys/acct.h Accounting header file that defines formats for writing accounting files.

SEE ALSO

Commands: acct(8), acctcms(8), acctcom(8), acctcon(8), acctmerg(8), acctprc(8), fwtmp(8), wtmpconvert(8). Daemons: cron(8) Functions: acct(2) System Administration

Index Index for
Section 8
Index Alphabetical
listing for R
Top of page Top of
page