Listing 1 A makefile to calculate the reports and send them by email
SUMDIR = /var/adm/acct/sum
FISCDIR = /var/adm/acct/fiscal
RALOG = /var/adm/acct/nite/fd2log
DAILY = $(shell ls -1tr $(SUMDIR)/rprt* | tail -1)
MONTHLY = $(shell ls -1tr $(FISCDIR)/fiscrpt* | tail -1)
TODAY = $(shell date '+%d')
MAKE = /usr/local/bin/make
reports:
if [ $(TODAY) -eq 1 ] ; then $(MAKE) report.monthly ; fi
$(MAKE) report.daily
report.daily:
cd $(SUMDIR) || exit 1
if [ -z "$(DAILY)" ] ; then exit 2 ; fi
cat $(DAILY) | mailx -s "`hostname`: acct daily report" root
report.monthly:
cd $(FISCDIR) || exit 1
if [ -z "$(MONTHLY)" ] ; then exit 2 ; fi
cat $(MONTHLY) | mailx -s "`hostname`: acct monthly report" root
runacct:
acctcom | mailx -s "`hostname`: commands accounting" root
/usr/lib/acct/runacct 2> /var/adm/acct/nite/fd2log
$(MAKE) runacct.log
$(MAKE) report.daily
runacct.log:
if [ -s $(RALOG) ] ; then cat $(RALOG) | mailx -s \
"`hostname`: runacct log" root ; fi
monacct:
/usr/lib/acct/monacct
$(MAKE) report.monthly
|