10

I'm on macOS 10.13.6.

I often need to set a long process running from the terminal, and then lock my Macbook for a while, and I want the process to be still running when the screen is locked. However, the process just hangs as long as the screen is locked. I can confirm that the Macbook is not asleep, and I've checked the box that says "prevent computer from sleeping automatically when the display is off" in "Energy Saver". How do I keep the process running (not hang) when the computer is locked (but not asleep)?

7
  • Can you elaborate on what process are you talking about?
    – Nimesh Neema
    Commented Oct 11, 2018 at 9:52
  • Any long-running process. A machine learning training run for example. More concretely, a Python program that takes ages (hours) to run.
    – Ray
    Commented Oct 11, 2018 at 10:06
  • Do you use a sleep prevention app like Caffeine or KeepingYouAwake? apple.stackexchange.com/questions/89277/… and apple.stackexchange.com/questions/76107/…
    – Nimesh Neema
    Commented Oct 11, 2018 at 10:16
  • I've heard of them, but as I said, the computer is not asleep. It's merely locked.
    – Ray
    Commented Oct 11, 2018 at 10:45
  • I inferred that from the question. I was simply suggesting giving it a try and making observation.
    – Nimesh Neema
    Commented Oct 11, 2018 at 10:47

2 Answers 2

5
  1. In System Preferences > Energy Saver, check the box for "Prevent computer from sleeping automatically when the display is off" (on laptops, this is under the Power Adapter tab)
  2. In System Preferences > Security & Privacy, check the box for "Require password after sleep or screen saver begins" and set the delay in the dropdown menu to "immediately"

Now, you can hit command-option-power to turn off the display without sleeping the computer, and doing anything that turns on the display (like hitting a key or clicking a mouse button) will prompt you for your account password.


Credits: This answer

1
  • 1
    Both are already ticked. In fact I've already mentioned in my question precisely what you mentioned in your point 1. This does not answer my question at all.
    – Ray
    Commented Oct 12, 2018 at 9:11
0

In addition to the answer by @haran-rajkumar , I've found I need to also do the following to keep things like ssh sessions open and maven builds running in the Terminal app. The preferences below are from Monterey...

  1. In System Preferences > Battery > Battery menu item, un-check the "Put hard disks to sleep when possible".
  2. In System Preferences > Battery > Power Adapter menu item, un-check the "Put hard disks to sleep when possible".

You must log in to answer this question.

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