Turn off screen on a headless machine

While playing with my homelab Forgejo instance, I needed a place where actions could be run. I was considering a virtual machine on my NAS but in the end, I dug up an old laptop that I haven’t been using for anything for quite a while, mostly because it’s a bit heavy (16″), the battery is half-dead and the TN screen is not great. But even though it’s a bit older, like ten years, it’s still a fairly decent machine with eight cores and 16 GB of RAM – more than enough to serve as an occasional headless forgejo action runner. I only wake it up with WOL only when it’s needed, it doesn’t have to run 24/7.

There was no desktop environment needed so it was a headless machine that went to a terminal after boot. I wanted to blank the screen after the boot but it wouldn’t happen on its own. At first, I tried turning it down by running setterm in a script one minute after the boot but it didn’t work:

#!/bin/bash
sleep 60
setterm --powerdown=1 < /dev/tty1

What did work though was updating the grub config so that it contains this line:

# cat /etc/default/grub
...
GRUB_CMDLINE_LINUX="consoleblank=60"
...

After that, the screen would blank one minute after the boot.