Skip Navigation

Systemd: Hidden Gems for a Better Linux // Self-host more with less hardware

tadeubento.com Systemd: Hidden Gems for a Better Linux

Systemd is incredibly versatile and most people, including myself, are unaware of its full potential. Despite its usefulness, it is often overlooked due to controversy and the current state of things when it comes to software development. Begin today your journey thought Systemd's capabilities and d...

Systemd: Hidden Gems for a Better Linux

After a few conversations with people on Lemmy and other places it became clear to me that most aren't aware of what it can do and how much more robust it is compared to the usual "jankiness" we're used to.

In this article I highlight less known features and give out a few practice examples on how to leverage Systemd to remove tons of redundant packages and processes.

And yes, Systemd does containers. :)

Linux @kbin.social

Systemd: Hidden Gems for a Better Linux

10 2
homelab @lemmy.ml

Systemd: Hidden Gems for a Better Linux // More Homelab with less Hardware

14 4
Linux @lemmy.ml

Systemd: Hidden Gems for a Better Linux

327 90
19 comments
  • Love me some systemd timers. Much more fun than cron.

    • Sane handling of environment variables with EnvironmentFile=
    • Out of the box logging. Especially useful is the ability to journalctl -f to watch long-running processes, which I'm not sure whether possible with cron
    • The ability to trigger the service manually rather than setting the timer to * * * * *, then forgetting it's supposed to run in a minute, get distracted, come back in 15 minutes

    My only complaint is it's a bit verbose. I'd rather have it as an option inside the .service file. The .timer requires some boilerplate like [Unit].description (it... uh... triggers a service. that's the description), and WantedBy=timers.target. But these are small prices to pay

    • Another thing I particularly like is systemctl list-timers --all and its overview of the timer statuses and when they're going to run next.

    • My only complaint is it's a bit verbose. I'd rather have it as an option inside the .service file. The .timer requires some boilerplate like [Unit].description (it... uh... triggers a service. that's the description), and WantedBy=timers.target.

      This can be solved through abstraction and automation.

      In NixOS for example, you can declare a service that runs an arbitrary script every day like this:

       Nix
          
      {
        systemd.services.your-service-here = {
          script = "echo 'Hello, world!'";
          startAt = "daily";
        };
      }
      
        

      This automatically creates a service file with the script in its ExecStart and an accompanying timer which runs daily and is part of the timers.target.

      • Yep, I manage my servers and local machine with Ansible so I abstracted it with a role. This is indeed not that bad of a con because it's still plaintext so automation is easy, but it's still a minor issue ;)

19 comments