#!/bin/sh
# /etc/cron.daily/net-acct: nacctd daily maintenance script
# 
# Created Thu Jul 18 21:41:26 MET DST 1996 Bernd Eckenfels <ecki@debian.org>
#
# See /usr/doc/net-acct/ for informations
#
# bug #35538 is fixed, the pid file has to exist
#
test -d /var/log/net-acct   || exit 0;
test -r /etc/naccttab       || exit 0;
test -r /var/run/nacctd.pid || exit 0;
test -x /usr/sbin/nacctd    || exit 0;

cd /var/log/net-acct
umask 022

# Stop writing out entries
kill -TSTP $(cat /var/run/nacctd.pid)

# cycle logfiles (keep the last 14)
savelog -g root -m 644 -u root -c 14 net-acct.log >/dev/null

# save the last debug file, for inforation only. nacctd never closes this
# file, dont delete.
# yes, here is a race, but we dont need that data, anyway
cp net-acct.debug net-acct.debug.0
date > net-acct.debug

# Start writing out entries again
kill -CONT `cat /var/run/nacctd.pid`
