Knowledge base

delete-after

<acct-file>set by the Hub

How many days to keep closed accounting files
in the configuration this is a linedelete-after 8dinside the block <acct-file>
The only automatic cleanup of accounting

The line sets how many days the engine keeps a closed accounting file before deleting it. The default is 8d, and there is a never value.

🔴 It applies only while move-to is off. As soon as files start moving to another directory, the retention period does not apply to them at all — you have to look after the archive yourself.

This is the only automatic cleanup of accounting. Nothing else deletes the files; the node’s free space threshold concerns the spool and messages, not the accounting directory.

The period is set in days. This line has no smaller unit: an hour or a minute cannot be written here.

The main trap is enabling moving and not noticing that cleanup turned off along with it. Files keep appearing, now in the archive, and are never deleted. This is discovered through free disk space weeks or months later.
What the Hub does. It writes it — delete-after 7d in the file block.

Seven days work for us precisely because we do not set move-to. A week is a sensible period: the main stream goes out via webhook and sits in our database, while the file is read by the “Accounting stats” module and is also needed to reconcile or recover a gap over the recent period.

Recommended values

The period is matched to why the file is needed at all:

Value When
7d–8d the file is a backup, the main accounting goes elsewhere
30d and more the file is the only source of statistics
never the files are picked up and deleted by an external collector

With moving enabled the line does not apply — with any value.

The 8d default, the never value and the “only with move-to off” rule come from the manual (§ 3.3.11.1). The analysis of our period is based on the Hub template.
Example configuration
# a week for the backup file: the main accounting goes out via webhook
<acct-file /var/log/pmta/acct.csv>
    max-size 25M
    delete-after 7d</acct-file>
It is worth checking that there is no move-to next to it: with it this line does nothing, and the directory will grow.
yellow — — directive names, blue — blocks. They are highlighted the same way in the text of the card.
▲

Common mistakes and problems

what people get wrong and how it ends2 mistakes▶

Enabling moving and losing automatic cleanup

§ 3.3.11.1

What it costsThe retention period stops applying. Files pile up in the destination directory indefinitely, and it becomes noticeable through free space, not through an error.
How to spot itThe archive has files older than the set period.
How to do it rightClean the archive with your own tools — on a schedule or with the operating system’s rotation.

Setting the period in hours

our experience

What it costsThe only unit here is days. The engine will not accept a value with another unit, and the configuration will fail the check.
How to spot itpmta test config complains about the directive’s value.
How to do it rightSet it in days; for more frequent cleanup use the file size and external rotation.
Compatibility
PowerMTA 6.0
described in the manual of this version · platform: any
The vendor does not state the first version for every directive — there is no note here. The name also appears in the 5.0 edition of the manual.
Reference data
Syntax
delete-after <retention>
Values
Nd — a number of days, or never
Default
8d § 3.3.11.1
Applying
reload, no restart needed
Queue
will not touch what is already queued
Where to write it
<acct-file>
How many times
once in the block
Everything here comes from the manual, with the section.
Inheritance
There is no inheritance: the line lives inside its <acct-file> and concerns only its files. Different accounting streams can be kept for different periods.
How to check on the node
The check is direct — the oldest file in the directory must not be older than the period:
ls -la --time-style=long-iso /var/log/pmta/acct*.csv | head -3
Files older than the set period mean cleanup is not working. The first thing to check is whether move-to is set next to it.
In the Hub
Managed at
Analytics → Node accounting
Value
The Hub picks it itself — pace, warm-up stage, metrics
Cost of a mistake
reversible: harms only while it is set
Scenarios
Collect telemetry