---
title: "Run Philter Diffuse on a schedule with a persistent privacy budget"
description: "Run Philter Diffuse from cron or a CI job with its Docker image, keep the privacy budget between runs, handle a refused release, and raise or reset the ceiling deliberately."
url: "https://philterd.ai/guides/run-philter-diffuse-on-a-schedule/"
---

[Knowledge base](https://philterd.ai/guides/) [How-to](https://philterd.ai/guides/?kind=how-to)

# Run Philter Diffuse on a schedule with a persistent privacy budget

Run Philter Diffuse from cron or a CI job with its Docker image, keep the privacy budget between runs, handle a refused release, and raise or reset the ceiling deliberately.

For [Philter Diffuse](https://philterd.ai/support/philter-diffuse/)

A scheduled report runs [Philter Diffuse](https://philterd.ai/philter-diffuse/) again and again, and every run is a new release that spends privacy budget. The budget only protects anything if it outlives each run. A container that keeps its budget inside itself starts from zero every time, and the ceiling never stops a release.

This guide runs the Philter Diffuse Docker image from a scheduler with the budget on a volume, decides what each budget should cover, and handles the run that the ceiling refuses. For choosing the PII types, the noise scale, and the threshold, see [Publish PII counts with differential privacy](https://philterd.ai/guides/publishing-pii-counts-with-differential-privacy/).

![A scheduler such as cron or a CI job starts the Philter Diffuse container for each release, and the container is removed afterwards. The spent budget is kept in privacy\_budget.json on a volume mounted at /data, so it carries over. At epsilon 2.0 a release, runs 1 to 5 bring the total to 10.0, and run 6 is refused with exit status 1 because it would pass the ceiling. Without the volume, every run would start from zero, so spending would never accumulate toward the ceiling.](https://philterd.ai/images/guides/guide-diffuse-scheduled-budget.svg)

The examples use the `philterd/philter-diffuse:0.1.0` image and JSON input. Version 0.1.0 can also read counts from Philter’s API. Per-day budgets for those reads need a build from the repository; see [Release daily PII counts from Philter](https://philterd.ai/guides/release-daily-pii-counts-from-philter-with-philter-diffuse/).

## 1\. Keep the budget on a volume

The image runs from `/data` and keeps the budget in `/data/privacy_budget.json`. Mount a directory there that holds the input, the output, and the budget:

```bash
docker run --rm --user "$(id -u):$(id -g)" -v /srv/diffuse-data:/data \
  philterd/philter-diffuse:0.1.0 \
  --input pii_counts.json \
  --source claims-intake \
  --pii-types ssn,email-address,phone-number,passport \
  --threshold 10 \
  --output pii-counts.csv
```

The image runs as UID 1000. `--user` runs it as you, so it can write to a directory you own. After the run, the directory holds:

```text
pii-counts.csv
pii_counts.json
privacy_budget.json
privacy_budget.json.lock
```

A new `privacy_budget.json` is created readable by its owner only, and each update replaces it in one step so a crash cannot leave half a file. The `.lock` file serializes runs that share the budget file on the same machine. Back the budget file up with the reports. A file that cannot be read stops the run rather than starting again from zero:

```text
Loading counts from pii_counts.json...
Error: The privacy budget file /data/privacy_budget.json is not valid JSON. Restore it from a backup.
```

In a CI job, the runner and its workspace are usually thrown away after each job. Keep the budget file on storage that outlives the runner, and do not let two jobs that share a budget file run at once.

## 2\. Decide what one budget covers

The budget is tracked under the `--source` name, and it never renews by itself. How you name sources decides how many releases a schedule gets.

- **Counts that grow over time.** If each run releases running totals for the same data, keep one source name. Every release adds to its budget. At four types and the default scale of 2.0, a release costs epsilon 2.0, so the default ceiling of 10.0 allows five releases in all. Plan the schedule around that number.
- **Counts for separate periods.** If each run releases counts for documents no earlier release covered, such as last month’s redactions, give each period its own source name. A new name starts a new budget, and that is sound because no document appears in two periods.

Choose the naming before the first release. Renaming the source of running totals to get a fresh budget removes the protection the ceiling gives.

## 3\. A monthly job

This script releases last month’s counts, from a file named for the month that the pipeline writes, under a source named for the month:

```bash
#!/bin/bash
# Release last month's PII counts. Run from cron on the first of each month.
set -euo pipefail

DATA_DIR=/srv/diffuse-data
PERIOD=$(date -u -d "$(date -u +%Y-%m-01) -1 day" +%Y-%m)

docker run --rm --user "$(id -u):$(id -g)" -v "$DATA_DIR":/data \
  philterd/philter-diffuse:0.1.0 \
  --input "pii_counts_${PERIOD}.json" \
  --source "claims-intake-${PERIOD}" \
  --pii-types ssn,email-address,phone-number,passport \
  --threshold 10 \
  --output "pii-counts-${PERIOD}.csv"
```

```text
0 6 1 * * /usr/local/bin/release-pii-counts.sh
```

Run on December 1, it releases `pii_counts_2026-11.json` to `pii-counts-2026-11.csv`. The noised counts differ on every run:

```text
PII Type        | Private 
----------------------------------------
ssn             | 409     
email-address   | 3869    
phone-number    | 2216    
passport        | None    
```

The budget file then holds one entry per source:

```json
{"claims-intake": 10.0, "claims-intake-2026-11": 2.0}
```

## 4\. When the ceiling refuses a release

A release that would pass `--budget-ceiling` writes nothing, leaves the earlier output file as it was, charges nothing, and exits with status 1. This is the sixth release of the running totals above:

```text
Error: This release costs epsilon 2, and claims-intake has spent 10 of its budget ceiling of 10. Nothing was released and no budget was spent. Raise --scale or list fewer types to spend less.
```

With `set -e`, the script exits with that status too, so make the scheduler report it: cron’s `MAILTO`, a failed CI job, or your monitoring. Do not treat a refusal as a report of zero, and do not retry it automatically. The options are the ones the message gives, and they are decisions:

- **Spend less per release.** A higher `--scale` or a shorter `--pii-types` list lowers the cost, at the price of noisier or fewer counts.
- **Wait for new data.** For counts by period, the next period has its own budget.
- **Raise the ceiling.** Passing `--budget-ceiling 12` lets the release above go through and records 12.0 spent. The ceiling is the most privacy loss you accept for that data, so raise it only as a decision you could explain, and pass the new value on every later run.

## 5\. Resetting a budget

To reset a budget, remove its entry from the budget file, or delete the file. That is sound only when later releases leave out every document an earlier release covered. Releasing running totals again after a reset adds to the privacy loss of the old documents, and Philter Diffuse cannot tell. Counts for a new period need no reset: give them a new source name.

Reusing a released CSV costs nothing. Point dashboards and reports at the files the schedule writes, not at Philter Diffuse.

## Where to go next

- [Publish PII counts with differential privacy](https://philterd.ai/guides/publishing-pii-counts-with-differential-privacy/) covers what the bound means and how to pick the scale and types.
- [Release daily PII counts from Philter](https://philterd.ai/guides/release-daily-pii-counts-from-philter-with-philter-diffuse/) covers Philter’s API, where the budget is kept per UTC day.
- The [Philter Diffuse documentation](https://philterd.github.io/philter-diffuse/privacy-budget/) describes the budget file in full.

Differential privacy limits what a release reveals about one document. A person who appears in many documents is protected less, in proportion, and the released counts are not anonymous in a legal sense. It is one control that supports your compliance efforts, so validate the settings against how your own data is structured.
