Reduce Cron Email Noise with logdiff

Date: Fri, Nov 28, 2025

Tag(s): Logdiff Cron Logs Devops Rust Open-Source CLI

If your cron jobs or scheduled scanners flood your inbox with the same output every run, it becomes hard to spot the important changes. logdiff is a tiny open-source Rust tool that caches streamed output per key and emits only the differences from the previous run - either as a unified diff or as changed lines only. That makes email notifications and alerts far more actionable.

Why this matters

What logdiff does

Quick install

Install with Cargo:

cargo install --git https://codeberg.org/chapati/logdiff logdiff

Or build from source:

git clone https://codeberg.org/chapati/logdiff
cd logdiff
cargo build --release
# binary will be in target/release/logdiff

Usage examples

Pipe a logfile into logdiff with a key. The first run creates the baseline and prints nothing:

cat logfile.log | logdiff mykey

On the next run it prints the unified diff between the previous and current input. To receive only the changed lines (prefixed with + or -) use:

cat logfile.log | logdiff --only-lines mykey

Cron example (practical)

Here is a real-world cron line that runs lynis daily at 04:30, filters the output through logdiff and mails only the changed lines:

30 4 * * * (lynis --cronjob 2>&1 | logdiff --only-lines lynis | mail -s "san: lynis" [email protected])

How this helps

Advanced tips

Cache location and fallback

By default logdiff stores cache files in $XDG_CACHE_HOME/logdiff or ~/.cache/logdiff. It relies on the system diff tool; when diff is unavailable logdiff falls back to a manual comparison implementation.

License & repo

logdiff is open source under the AGPL-3.0 license. Check the project, file issues, or contribute at:

https://codeberg.org/chapati/logdiff

This small CLI tool is ideal for anyone who wants fewer, more useful notifications from scheduled tasks. Drop it into your cron pipelines and get alerts that actually matter.