You can set up system accounting to run while the system is in multiuser mode (system state 2). Generally, this involves:
Creating /etc/rc0.d/K22acct and /etc/rc2.d/S22acct.
Modifying /var/spool/cron/crontabs/adm and /var/spool/cron/crontabs/root.
Most of the accounting scripts are added to the /var/spool/cron/crontabs/adm database file. Table 60-1 describes the default accounting scripts.
Table 60-1 Default Accounting Scripts
Accounting Script ... |
Is Used To ... |
And Runs ... |
---|---|---|
ckpacct |
Check the size of the /usr/adm/pacct log file |
Periodically |
runacct |
Process connect, process, disk, and fee accounting information |
Daily |
monacct |
Generate fiscal reports and is run once per period |
On a fiscal basis |
You can change these defaults. After these entries have been added to the database and the accounting programs have been installed, accounting should run automatically.
Become superuser.
If necessary, install the SUNWaccr and SUNWaccu packages on your system by using the pkgadd or admintool command.
Install /etc/init.d/acct as the startup script for Run Level 2.
# ln /etc/init.d/acct /etc/rc2.d/S22acct |
Install /etc/init.d/acct as the stop script for Run Level 0.
# ln /etc/init.d/acct /etc/rc0.d/K22acct |
Modify the admcrontab file to start the ckpacct, runacct, and monacct programs automatically.
# EDITOR=vi; export EDITOR # crontab -e adm 0 * * * * /usr/lib/acct/ckpacct 30 2 * * * /usr/lib/acct/runacct 2> /var/adm/acct/nite/fd2log 30 7 1 * * /usr/lib/acct/monacct |
Modify the root crontab file to start the dodisk program automatically.
# crontab -e 30 22 * * 4 /usr/lib/acct/dodisk |
Edit /etc/acct/holidays to include national and local holidays, by using the editor of your choice.
Reboot the system, or type
# /etc/init.d/acct start |
The following example shows how the crontab entries that run /usr/lib/acct/ckpacct, /usr/lib/acct/runacct, and /usr/lib/acct/monacct have been added to /var/spool/cron/crontabs/adm.
#ident "@(#)adm 1.5 92/07/14 SMI" /* SVr4.0 1.2 */ # # The adm crontab file should contain startup of performance # collection if the profiling and performance feature has been # installed. 0 * * * * /usr/lib/acct/ckpacct 30 2 * * * /usr/lib/acct/runacct 2> /var/adm/acct/nite/fd2log 30 7 1 * * /usr/lib/acct/monacct |
The following example shows how the crontab entry that runs /usr/lib/acct/dodisk has been added to /var/spool/cron/crontabs/root.
#ident "@(#)root 1.12 94/03/24 SMI" /* SVr4.0 1.1.3.1 */ # # The root crontab should be used to perform accounting data # collection. # The rtc command is run to adjust the real time clock if and when # daylight savings time changes. # 0 2 * * 0,4 /etc/cron.d/logchecker 5 4 * * 6 /usr/lib/newsyslog 15 3 * * * /usr/lib/fs/nfs/nfsfind 1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1 20 * * * * [ -x /usr/lib/inet/ntpdate ] && /usr/lib/inet/ntpdate -m 224.0.1.1 >/dev/null 2>&1 30 22 * * 4 /usr/lib/acct/dodisk |
The following example shows a sample /etc/acct/holidays file.
* @(#)holidays January 1, 1997 * * Prime/Nonprime Table for UNIX Accounting System * * Curr Prime Non-Prime * Year Start Start * 1997 0800 1800 * * only the first column (month/day) is significiant. * * month/day Company * Holiday * 1/1 New Years Day 1/20 Martin Luther King's Day 2/17 President's Day 5/26 Memorial Day 7/3 Day before Indep. Day 7/4 Indep. Day 9/1 Labor Day 11/27 Thanksgiving 11/28 Day after Thanksgiving 12/25 Christmas 12/26 Winter Break 12/29 Winter Break 12/30 Winter Break 12/31 Winter Break |