Results 1 to 3 of 3

Thread: is powernap still around?

  1. #1
    Join Date
    Jul 2015
    Beans
    1

    is powernap still around?

    Hello
    I am back w/ essentially the same situation I've encountered before:
    I have a couple of desktops that i would like to automatically suspend when nobody is logged in. Also a couple of headless servers that i'd like to suspend on a schedule. I have used powernap for a long time, as recently as w/ 18.04. However I recently upgraded to 20.04 and powernap appears to be obsoleted and removed from the standard repositories. I'd appreciate any suggestions about accomplishing what i need to do.

    Edit:
    It dawned on me that i think I can adequately control the servers using cron and rtcwake. With the desktops, I guess I need a simple way to detect if any users are logged in, so that is a corollary question.
    Last edited by dlbrewe; December 30th, 2022 at 06:14 PM.

  2. #2
    Join Date
    Mar 2010
    Location
    USA
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: is powernap still around?

    I see 'powernap' list in focal (20.04) but diving deeper, I don't see it further than 18.04(???)

    On checking for logged in users...
    Code:
    #!/bin bash
    
    logged_in=$(w | grep -v 'average\|LOGIN@' | awk '{print $1}') ## Check for logged in users, return UserName
    
    if [ -z $logged_in ]
    then
      echo "No one is logged in"
      #systemctl suspend   ##hibernate 
      rtcwake -m disk -s 900   ## Hibernate to disk and wake up in 15 minutes...
    else
      echo "Users are logged in"
    fi
    The problem would be to power back on via command line... Using rtcwake, you could wake up in 15 minutes, then check for activity again (cron running this scipt)
    Last edited by MAFoElffen; December 31st, 2022 at 04:05 PM.

    "Concurrent coexistence of Windows, Linux and UNIX..." || Ubuntu user # 33563, Linux user # 533637
    Sticky: Graphics Resolution | UbuntuForums 'system-info' Script | Posting Guidelines | Code Tags

  3. #3
    Join Date
    Mar 2014
    Beans
    39

    Re: is powernap still around?

    Thanks for the ideas! I'm not sure I follow the details but I came up with a simple solution that seems to work well enough for me.

    logins=$(users)

    if [ "$logins" = "" ]; then
    systemctl suspend
    fi

    I run this script at intervals from /etc/crontab. So far it seems to work well enough.

    Thanks again. (BTW somehow I have two ubuntu forums accounts and logged in to the other one to post this question.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •