2025-07-09 systemd timers for the Butlerian Jihad

I was reading a post about the good parts of systemd (systemd has been a complete, utter, unmitigated success) and started wondering about the use of timers instead of cron jobs.

systemd has been a complete, utter, unmitigated success

The benefits:

And if every job is a complete script, then I can also add more stuff, like lowering the limits if load starts to overshoot again.

So here we go.

I have four jobs:

Each of them gets a service and a timer.

Since I wanted the service to protect a good part of the system, I had to move things around a bit.

`asncounter`

I had to install asncounter in `/usr/local`. Since I already had a copy of it all I just moved things around, but things to work out next time, my `root` user has `PIPX_HOME` set to `/usr/local/pipx`. This is very messy. I hope that `asncounter` makes it into Debian, soon. ❤️

asncounter

So:

I also edited the first line of `asncounter` to read as follows:

`/etc/butlerian-jihad`

I created this directory for the scripts and its dependencies.

10min-access-log

2h-access-log

asn-networks

I also create a `data` directory here for the `pyasn` data. This is not the default location so we must always pass `--cache-directory /etc/butlerian-jihad/data` when running `asncounter`.

scripts

The scripts all exclude some more IP numbers in their call to `2h-access-log` (my home IP addresses, my server's IP addresses) so I don't accidentally ban myself, as well as the `social` subdomain which is where my fedi instance is. In addition to that, my IP addresses are also in the allow-list that I use for various things (fediverse servers I am connected to, friends using dubious internet service providers).

`watch-active-autonomous-systems`

`watch-expensive-end-points`

`watch-nobots`

`watch-attempted-edits`

This watches "attempted edits" -- bots requesting the edit page and never posting anything. A clear sign of bot activity, if you ask me.

`attempted-edits`

`*.service`

Each script gets a service file. I'm only going to post `watch-active-autonomous-systems.service`. The only thing that changes from service to service is the `Description` and the `ExecStart` naming the script to run.

`*.timer`

Each script gets a timer file. I'm only going to post one of them. The only thing that changes from service to service is the `Description` as by default the timer applies for the service with the same name. Win!

I'm adding a `RandomizedDelaySec` of two minutes, hoping that over time the three timers will start to diverge.

systemd cheat-sheet

​#Administration ​#Butlerian Jihad ​#systemd