• Automatic suspend-to-ram solution for Workstations

    From Felix Natter@21:1/5 to All on Sat Dec 7 20:30:01 2024
    Dear Debian users,

    I am looking for an automatic suspend-to-ram (I know "sudo systemctl
    suspend" ;-)) solution for workstations: I would like the system to
    suspend if and only if:

    - there is no gui interaction from any user (especially with VNC
    sessions) AND

    - there is no significant load during the last hour (in order to account
    for backup jobs)

    I am using the mate desktop, if that makes any difference.
    Of course the desktop must be locked before suspension.

    Maybe systemd can support this in coop with the DE?

    I think Windows can do it, but Windows does not allow multiple users
    logged in at the same time, so it is an easier task.

    Am I asking too much?

    Many Thanks in Advance!
    Felix
    --
    Felix Natter

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Will Mengarini@21:1/5 to All on Sat Dec 7 21:20:01 2024
    * Felix Natter <fnatter@gmx.net> [24-12/07=Sa 20:27 +0100]:
    [...] no significant load during the last hour [...]

    The system doesn't keep track of load for a
    full hour, but it does for fifteen minutes.
    uptime|awk '{print $NF}'
    is load average for the past 15 minutes.

    [...] no gui interaction [...] (especially with VNC [...]) [...]

    That's a lot harder. Theoretically `w` shows idle time, but
    I'm not sure you can trust it with layers of GUI interaction.

    Full original post:
    I am looking for an automatic suspend-to-ram (I know "sudo systemctl
    suspend" ;-)) solution for workstations: I would like the system to
    suspend if and only if:

    - there is no gui interaction from any user (especially with VNC
    sessions) AND

    - there is no significant load during the last hour (in order to account
    for backup jobs)

    I am using the mate desktop, if that makes any difference.
    Of course the desktop must be locked before suspension.

    Maybe systemd can support this in coop with the DE?

    I think Windows can do it, but Windows does not allow multiple users
    logged in at the same time, so it is an easier task.

    Am I asking too much?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anssi Saari@21:1/5 to Felix Natter on Mon Dec 9 14:00:01 2024
    Felix Natter <fnatter@gmx.net> writes:

    Dear Debian users,

    I am looking for an automatic suspend-to-ram (I know "sudo systemctl
    suspend" ;-)) solution for workstations: I would like the system to
    suspend if and only if:

    - there is no gui interaction from any user (especially with VNC
    sessions) AND

    I think every desktop environment has this. Even X has this. 'This'
    being a timer since last mouse or keyboard event and the ability to
    trigger a command on the timer. I looked recently but didn't really find
    a way to do the Windows like thing, turn off screen->suspend->hibernate
    with configurable intervals. Desktop environments do have that and KDE
    does it fine on my Linux laptop but with just X11 and a WM it's a
    different story.

    - there is no significant load during the last hour (in order to account
    for backup jobs)

    This is the hard part, define load. Especially now that the logged in
    user might have a browser running with a few dozen or a few hundred
    tabs, all full of Javascript code, some of which probably wants to run sometimes or all the time.

    I think Windows (and maybe Macs?) have gone the other way, they have
    process settable bits to indicate system is in use. Handy for video
    players, for example, but backup jobs too. I don't know if Linux has
    anything like that. Well, you can disable the X screensaver which
    probably works for movies but that doesn't matter a whole lot to a batch
    backup job.

    I think Windows can do it, but Windows does not allow multiple users
    logged in at the same time, so it is an easier task.

    At least today's Windows (10 and 11) do allow multiple users logged in
    and I think XP over two decades ago had "switch user" in there, allowing multiple simultaneous logins.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jan Claeys@21:1/5 to Felix Natter on Fri Dec 13 17:50:01 2024
    On Sat, 2024-12-07 at 20:27 +0100, Felix Natter wrote:
    - there is no significant load during the last hour (in order to
    account for backup jobs)

    Assuming this backup is started by an automated system under control of
    the sysadmins, and not by the users themselves, it's probably easiest
    to use some sort of "lock" that is set by the backup process itself (or
    that you wrap around it).

    Otherwise there probably isn't any good, error-free way to determine
    what "load" should inhibit sleep or not...


    --
    Jan Claeys

    (please don't CC me when replying to the list)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Henrik Ahlgren@21:1/5 to Jan Claeys on Fri Dec 13 18:30:01 2024
    On Fri, 2024-12-13 at 17:44 +0100, Jan Claeys wrote:
    Assuming this backup is started by an automated system under control of
    the sysadmins, and not by the users themselves, it's probably easiest
    to use some sort of "lock" that is set by the backup process itself (or
    that you wrap around it).

    Set up a systemd timer job for automatic backups, using WakeSystem=true
    to make RTC resume the system if it is suspended during when the backup
    is scheduled to run. Then wrap the backup command with "systemd-inhibit --what=idle" to keep the system awake during the backup process.

    The only problem I've seen with this setup is that even with

    After=network-online.target nss-lookup.target
    Wants=network-online.target nss-lookup.target

    the network isn't always fully online when the job starts. Does anyone
    know a reliable way of ensuring that with systemd configuration
    (without workarounds like sleep-before-starting)? Any why doesn't network-online.target work when resuming from sleep?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)