Using jq to extract a single field from nested JSON logs

Extracting a Single Field from Nested JSON Logs with jq

Running a homelab or a tiny self‑hosted service usually means dealing with JSON‑encoded logs. Whether it’s systemd‑journal, docker logs, or a custom app, the output is often a tidy JSON object per line. The catch? Those objects are usually nested, and if you only care about one value—like the HTTP status code or a user ID—you’ll waste a lot of time sifting through the whole file. That’s where jq steps in.

[Read More]

Safely Deleting Old Log Files with find and xargs

Avoiding destructive mistakes when cleaning up logs

The “find + xargs” combo is a classic for cleaning up old logs, but it can be a double‑edged sword if you’re not careful.

Below is a step‑by‑step guide that shows how to target only the log files you want to delete, keep your home folder safe, and understand the trade‑offs of the different options you’ll see.


Why find and xargs instead of rm -r?

find is the Swiss‑army knife of file searching: you can filter by name, age, size, permissions, and more.
xargs takes the list that find spits out and feeds it to another command, usually rm.
The pair is efficient because it processes files in batches, sidestepping the “argument list too long” error that can bite you if you try to delete thousands of files with a single rm.

[Read More]