• Ignotum@lemmy.world
    link
    fedilink
    arrow-up
    92
    ·
    edit-2
    19 hours ago

    was i supposed to find that out by myself

    Just do what i did, wait for someone to post about it on lemmy then learn about it from that
    That’s actually how i learned most of the things i know

  • gazter@aussie.zone
    link
    fedilink
    arrow-up
    23
    ·
    18 hours ago

    Linux newb here. What does this mean? My knowledge of systemd is that it is responsible for things like mounting disks and running networking. So does this mean I can ask systemd to grab a new IP address every x hours, even if the machine is asleep?

    • Björn TantauOPA
      link
      fedilink
      arrow-up
      8
      ·
      8 hours ago

      Systemd at its core starts stuff when your Linux system boots and during normal operation. It can also start stuff at specific times. That was traditionally done by cron.

      But of course when you set up to run something at midnight it cannot run if the system is in standby. But with the WakeSystem=true option you can tell it to basically set an alarm for the computer to turn itself back on and do whatever you want it to do.

      It does not turn your computer back to sleep, though. That’s something you have to script yourself.

      I hope they add the ability to turn the computer on even if it is completely shut off. That would make keeping my family’s computers updated much easier.

      • KaninchenSpeed@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        4 hours ago

        I hope they add the ability to turn the computer on even if it is completely shut off. That would make keeping my family’s computers updated much easier.

        That’s probably not possible, but you could do it with a microcontroller and a relay bridging the power switch.

        • Björn TantauOPA
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          26 minutes ago

          If you read the corresponding feature request it actually seems to be pretty easy. They were just arguing about implementation details.

          Windows has supposedly also done this for a while now.

          Of course it depends on hardware capabilities. But I guess it’s common enough now.

          Edit: This is actually trivial to implement with the rtcwake command. Usually available in linux-utils or similar packages. rtcwake --list-modes shows you what modes your system supports.

    • rtxn@lemmy.worldM
      link
      fedilink
      arrow-up
      21
      arrow-down
      1
      ·
      edit-2
      17 hours ago

      Systemd is a collection of low-level system utilities. Its primary responsibility is managing services and serving as the init process (PID 1, the first userspace process started by the kernel), but it also has other components, like systemd-boot (a boot loader and GRUB alternative), journald (system logging), networkd (network interface management), resolved (DNS resolver), or udevd (manages device files in /dev).

      People tend to vilify systemd because it is maintained by Red Hat, a company with many controversies, and a pariah among the more extreme FOSS enthusiasts; and because it’s seen as bad practice to have a single entity be responsible for so many low-level system components.

      Note: the -d suffix is not exclusive to systemd things. It simply marks the program as a daemon, a long-running background process that provides some kind of service. For example, sshd (SSH server) or httpd (Apache server on some distros) are not parts of systemd.

      To answer your question: not really. As far as I know, the network interface won’t have an IP address unless the computer is turned on. If you use a timer (or any other method for that matter) to power on the computer, it will request an address from DHCP as soon as the interface is brought up (unless it has a static address).

      A more practical application would be scheduling long, unattended tasks, like updates or making backups.

      • SEND_BUTTPLUG_PICS@lemmy.zip
        link
        fedilink
        arrow-up
        2
        ·
        11 hours ago

        Is sshd really not part of systemd? I seem to remember needing to run systemctl restart sshd after making changes to the sshd config file but it’s been a while since I’ve done that.

        I also use systemd to automatically start plex, sonarr, radarr, transmission, and maybe a few other things as well and if they need to be restarted I’d use a similar command on Ubuntu. Or I’d run systemctl status plexmediaserver to see if it was running correctly.

        I’m not an expert though so maybe I’m doing it wrong or using the wrong terminology.

        • rtxn@lemmy.worldM
          link
          fedilink
          arrow-up
          8
          ·
          9 hours ago

          Systemd, through the systemctl command, only manages the services. The service itself is defined in a unit file, and it can come from any source, even written manually. The unit file is a text file that describes what the service is, what commands or programs should be executed when it starts or stops (for sshd it’s /usr/bin/sshd -D), what other services or conditions are required (e.g. multi-user.target after the OS has entered multi-user mode), and much more.

          When a package installs a unit file, it will be installed to a subdirectory in /usr/lib/systemd, typically user or system, and when it is enabled, it will be symlinked to a subdirectory in /etc/systemd.

          OpenSSH itself, which provides sshd on most systems, is developed by the OpenBSD team and ported to other OSes by the OpenSSH Portability Team.

          • SEND_BUTTPLUG_PICS@lemmy.zip
            link
            fedilink
            arrow-up
            3
            ·
            8 hours ago

            That makes a lot of sense. I actually wrote my own unit files for Jackett and to autostart a virtual machine and moved them into multi-user target wants using the enable command. I guess my thought was that by adding the unit file to systemd it made the program part of systemd in a way but now that I think more about it, saying any of these programs are part of systemd doesn’t actually make sense. Just because sshd came pre-installed with Ubuntu doesn’t make it part of systemd any more than plex is part of systemd.

            Thanks for helping me understand!

        • Asparagus0098@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          4
          ·
          10 hours ago

          Is sshd really not part of systemd?

          Yes, it’s not a part of systemd. By running systemctl restart sshd you are just restarting the sshd systemd service. Systemd service files for things like ssh and transmission come with their respective packages.

          You can see what I mean here. The openssh-server package for Ubuntu comes with the sshd.service file.

          • SEND_BUTTPLUG_PICS@lemmy.zip
            link
            fedilink
            arrow-up
            1
            ·
            8 hours ago

            Yes my incorrect assumption was due to the fact that sshd came pre-installed with the OS unlike plex that came with its own service file or Jackett that I had to create the service file manually. Sshd is a program like any other that gets started by systemd. I appreciate the clarification!

    • Manifish_Destiny@lemmy.world
      link
      fedilink
      arrow-up
      8
      ·
      18 hours ago

      It basically means that systemd allows you to make a call to SYSTEM() using a specific command to wake the PC from hibernation, that way you can install updates in your script and then issue your sleep or shutdown command.

      Unless I’m missing something

      • WhyJiffie@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        5
        ·
        edit-2
        14 hours ago

        this can be useful, but hopefully it never becomes a default, it was enough of a pain when Windows was thinking that updates are more important than keeping the hibernated programs

  • Lucy :3@feddit.org
    link
    fedilink
    arrow-up
    29
    ·
    20 hours ago

    Though you still have to suspend by yourself when you’re done.

    Does

    ExecPost=systemctl suspend
    

    work ?

    • Björn TantauOPA
      link
      fedilink
      arrow-up
      32
      ·
      19 hours ago

      Probably.

      But what if the timer triggered during normal operation? Then your computer would suddenly suspend on its own and you wouldn’t know why.

      I’ve already made a feature request to only run when the system is suspended.

      Until then I’ll look at when the system woke up and if that was less than a minute ago turn off the display and suspend after everything is done.

    • nesc@lemmy.cafe
      link
      fedilink
      English
      arrow-up
      8
      ·
      19 hours ago

      Can’t you just suspend with another timer that calls Unit=suspend.target?

      • Björn TantauOPA
        link
        fedilink
        arrow-up
        4
        ·
        8 hours ago

        Yes, do that a minute after everything else started but run the services themselves with systemd-inhibit (another nice thing I didn’t know exists) so that it only goes back to sleep when the last service is done.