1

This question already has an answer here:

I am running a /Library/LaunchDaemons service at boot time - nobody is logged in. I want the computer to not sleep. Here's my pmset -g on macOS Sierra 10.12.4:

System-wide power settings:
Currently in use:
 standbydelay         4200
 standby              0
 womp                 1
 halfdim              1
 hibernatefile        /var/vm/sleepimage
 powernap             0
 gpuswitch            2
 networkoversleep     0
 disksleep            10
 sleep                0
 autopoweroffdelay    28800
 hibernatemode        0
 autopoweroff         0
 ttyskeepawake        1
 displaysleep         10
 acwake               0
 lidwake              1

Whenever I log in through SSH, it takes a while, and whenever I try to connect to my running service via HTTPS there is a long delay (10 seconds or so). It seems like the system is going to sleep. I can't figure out how to disable this.

I have logged in as a user (only user on system), and set computer sleep and display sleep to never, unchecked put hard disks to sleep, left wake for network access on, and unchecked power nap. This is all for Power Adapter mode. Automatic Graphics Switching is still enabled.

This seems mostly related to not having a user logged in. When I'm logged in, it doesn't go to sleep.

marked as duplicate by Allan, Monomeeth, user11633, fsb, IconDaemon May 15 '17 at 12:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Can you confirm that it is in fact going to sleep by checking it locally? Meaning, when you believe it's asleep go to the physical keyboard, and "wake it up." Is it immediate or does a it take a few seconds? – Allan May 12 '17 at 22:26
  • pmset -g log shows Maintenance Sleep. It looks like it might be due to the computer in clamshell mode (closed, no display connected). – nachum May 13 '17 at 0:45
  • Does InsomniaX work when no one has logged in? Looks like it's home page shows a "Start on Login" option, so I'm guessing not. – dwightk May 13 '17 at 13:43
  • My usecase has nobody logged in. Slightly different than the other question. – nachum May 14 '17 at 16:15
0

Go to System Preferences → Energy Saver and disable Put hard disks to sleep when possible.

  • I have already done this. Doesn't stop sleep in the case when nobody is logged in. – nachum May 11 '17 at 17:03
  • @nachum please be sure to add all relevant info to your question, including what you've already tried. This will prevent others from offering answers that you've already attempted. See How to Ask for tips on asking good questions. – fsb May 11 '17 at 19:12
0

Run a script based from a launchdaemon which checks for a user logged into console. who | grep console

Then disable sleep accordingly by using

caffeinate or pmset

Check their man pages for options. There are other ways of getting the logged in user as well.

Not the answer you're looking for? Browse other questions tagged .