9 comments

  • gchamonlive26 minutes ago
    Moved from cronie to systemd timers because they are resilient to system startup times. My backup strategy is to create a borg archive entry every day at a fixed time. With cronie the system needs to be running at the scheduled time, but systemd timer tolates this and runs the service as soons as the system is available.<p>Btw this is my repo for the backup automation: <a href="https:&#x2F;&#x2F;github.com&#x2F;gchamon&#x2F;borg-automated-backups" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gchamon&#x2F;borg-automated-backups</a>
  • stryan13 minutes ago
    Timers can work with arbitrary units (not just a similarly-named service unit) so they can be surprisingly flexible. I have a timer on my servers that starts a backup.target that fires off a full &quot;restic backup&quot;,&quot;restic prune&quot;, &quot;restic forget&quot; backup cycle each morning with randomized start times and notifications. The actual restic-* units are Podman Quadlets so the whole setup runs agnosticaly of what&#x27;s on the server, just as long as it has Podman and Systemd installed.<p>I will admit thought, timers are up there in terms of being the clunkiest systemd unit type to use on a regular basis. I get why they&#x27;re split up into two files and require different start vs enable syntax&#x27;s, but man sometimes I just want to create a file that runs a script and be done with it.
  • hombre_fatal57 minutes ago
    NixOS comes with systemd, so I&#x27;ve been using it as a first-class part of managing stuff. It&#x27;s great, especially coming from macOS&#x27; launchd.<p>Which makes it nice to distribute a tool for NixOS so that it can lean into systemd instead of as some bolted-on afterthought.<p>Makes me wonder what you&#x27;d do if you were distributing a lifecycle-heavy tool for Linux users in general since systemd isn&#x27;t ubiquitous.<p>I use a systemd timer to run a monthly scrub for my btrfs pool. Kinda cool how you can do increasingly useful things like skip the next scheduled event if the user initiates a scrub, do or don&#x27;t accumulate tasks if you have a monthly task but the machine was offline for 6 months -- or fold them into a single task, etc.
    • Cyph0n18 minutes ago
      +1, NixOS makes working with systemd a breeze. Defining units in Nix beats wrangling INI files.<p><pre><code> systemd.services.sync-recyclarr = { serviceConfig.Type = &quot;oneshot&quot;; path = [ pkgs.podman ]; script = &#x27;&#x27; podman exec -it recyclarr recyclarr sync radarr podman exec -it recyclarr recyclarr sync sonarr &#x27;&#x27;; }; systemd.timers.sync-recyclarr = { timerConfig = { OnCalendar = &quot;daily&quot;; Persistent = true; Unit = &quot;sync-recyclarr.service&quot;; }; partOf = [ &quot;sync-recyclarr.service&quot; ]; requires = [ &quot;podman-recyclarr.service&quot; ]; wantedBy = [ &quot;timers.target&quot; ]; };</code></pre>
    • drunner29 minutes ago
      Have you been defining them directly in your flake.nix file? I too am on nixos but I keep all my configurations in their native format and symlink them with nix, that way I can take and reuse that config on a non nixos system easily.<p>The problem I have found is that nixos doesn&#x27;t seem to pickup and run systemd timers and services placed into the ~&#x2F;.config&#x2F;systems&#x2F;user folder and additionally things like WantedBy=default.target have no effect.<p>So after I restart all my services manually on reboot I agree, systems timers are cool.
      • Cyph0n15 minutes ago
        I define all units in Nix because:<p>a) It is way nicer and you get decent validation at build time<p>b) A LLM can port units over if the need arises; it’s a very light abstraction around systemd syntax<p>c) I personally don’t see how I would ever move to another distro :)
  • ktm5j45 minutes ago
    Oh I love them quite a lot! I use them to run all of our backup jobs, easy to set up and have never had an issue.
  • andrewstuart28 minutes ago
    Even better is systemd socket activation.
    • interf4ce6 minutes ago
      This is very interesting. I&#x27;m not sure what I&#x27;d use it for yet, but I imagine it could be useful for triggering ad hoc jobs over the network. Maybe have Home Assistant make a network call to kick off a daily back up when I leave the office at the end of a work day.
  • jjgreen3 hours ago
    I&#x27;ve been almost convinced by systemd (and have switched to using it), but God the syntax of those service files is <i>so</i> ugly ...
    • zamadatix55 minutes ago
      Never thought I&#x27;d see hackers saying INI format looked ugly of all things. It&#x27;s basic, sure, but that&#x27;s a good thing for something meant to be easily editable by hand from any editor. Otherwise, it&#x27;s just key value pairs in named sections, how ugly can it be about that?
      • ramon15616 minutes ago
        TOML would look a lot more quiet, but I&#x27;m not sure if TOML would be a good fit
      • jjgreen46 minutes ago
        key-value pairs where the = cannot be surrounded by spaces, so I have to write<p><pre><code> [Service] Type=oneshot WorkingDirectory={{ home }}&#x2F;current&#x2F; Environment=RAILS_ENV=production ExecStart=&#x2F;bin&#x2F;sh -lc &quot;bin&#x2F;db-backup --verbose&quot; </code></pre> which fills me with sadness
        • voxic1112 minutes ago
          Whitespace immediately before or after the equals sign is completely ignored by the parser. Its the standard INI format.
        • yjftsjthsd-h22 minutes ago
          What? You absolutely can have spaces; most of mine look more like<p><pre><code> [Service] Type = oneshot WorkingDirectory = %h&#x2F;current&#x2F; Environment = RAILS_ENV=production ExecStart = &#x2F;bin&#x2F;sh -lc &quot;bin&#x2F;db-backup --verbose&quot;</code></pre>
          • jjgreen9 minutes ago
            Friend, you have changed my life
    • mrweasel42 minutes ago
      There&#x27;s definitely some weirdness to certain parts of systemd service files, but was a huge improvement over Upstart and the old SysV-style init scripts.<p>Over all I think Systemd get way to much criticism. You don&#x27;t have to use all the parts, but if you care to go through the documentation you&#x27;ll find interesting features such as journald log-shipping and systemd-machined which can manage containers and VMs.
    • SEJeff32 minutes ago
      Oh yes, because the well documented clean syntax of sys v init shell scripts was so nice.<p>If I never recall hacking in ulimit calls in the top of buggy shell scripts for crappy old services that done respect pam_limits it won’t be soon enough.
    • whateveracct57 minutes ago
      This is why I like NixOS. Defining systemd services in it is very neat.
    • WesolyKubeczek1 hour ago
      Could have been worse.<p>Could have been YAML.<p>Could have been XML.
      • silvestrov1 hour ago
        XML would have the advantage of having a grammar so we could validate the config files.<p>It would also make it much simpler to make good GUI editors for the files instead of the Notepad approach most unix config files take.
        • pwdisswordfishq16 minutes ago
          The systemd dialect of INI is actually pretty well-defined though.<p><a href="https:&#x2F;&#x2F;www.freedesktop.org&#x2F;software&#x2F;systemd&#x2F;man&#x2F;latest&#x2F;systemd.syntax.html" rel="nofollow">https:&#x2F;&#x2F;www.freedesktop.org&#x2F;software&#x2F;systemd&#x2F;man&#x2F;latest&#x2F;syst...</a>
        • WesolyKubeczek50 minutes ago
          Since systemd is successfully parsing its INI files, and barks at you when you put weird shit into them, a grammar for them does exist as well.<p>XML is that wonderful format that gave us vulnerabilities like death by million laughs, up to a certain moment, you could MitM DTDs, and a whole slew of everything-XML stuff back when XML was like AI is today, none of which I miss today.<p>Oh, and remember times when programmers would argue whether argument order in XML files should be significant or not?<p>But XML books with their idealized XML future description did give me the same warm fuzzies as some intricate clockwork mechanism to a Victorian geek.
        • Juliate58 minutes ago
          There are good GUI editors for XML?
      • jjgreen55 minutes ago
        To be honest, I think either of those would have been better ...
  • throwa35626258 minutes ago
    GNU&#x2F;Linux --&gt; Linux&#x2F;systemd
  • iso16311 hour ago
    &gt; humble systemd
    • pwdisswordfishq10 minutes ago
      That the same cannot be said of its maintainer is another matter.
  • iluvcommunism35 minutes ago
    [dead]