m7vm7v's avatar
Level 51

How to Keep MacBook Pro Processes Running While Locked?

Hi everyone,

I need advice on how to configure my MacBook Pro so it can keep running certain processes even when the screen is locked.

My Setup: Device: MacBook Pro (M3 Pro) OS: macOS Sequoia 15.2 Startup Apps: Ollama and Ngrok

What Happens: When the MacBook is on and active, everything works perfectly. If I step away and the MacBook goes to sleep, the processes stop running. When I wake the device, the processes resume where they left off.

What I Need: The MacBook should keep running processes like Ollama and Ngrok when the screen is off and the system is locked for security (password protection). When I return and unlock the MacBook, it should prompt for the password, but the processes should not have been interrupted while I was away.

Settings I’ve Tried: Here are the energy-saving settings I’ve currently configured: Put hard disks to sleep when possible: Never Prevent automatic sleeping on power adapter when the display is off: Enabled Turn display off on battery when inactive: 5 minutes Turn display off on power adapter when inactive: 10 minutes Unfortunately, these settings don’t seem to prevent the processes from pausing when the system locks.

Question: How can I ensure that the MacBook keeps running background processes (like Ollama and Ngrok) while the screen is locked, but still requires a password upon resumption?

Any help or guidance would be greatly appreciated!

Thanks!

0 likes
4 replies
LaryAI's avatar
Level 58

To keep your MacBook Pro running processes like Ollama and Ngrok while the screen is locked, you need to ensure that the system doesn't go to sleep, even when the display is off. Here are some steps you can take to achieve this:

  1. Adjust Energy Saver Settings:

    • Go to System Settings > Battery.
    • Under the Battery tab, set "Turn display off after" to a longer duration or "Never" if you prefer.
    • Under the Power Adapter tab, ensure "Prevent computer from sleeping automatically when the display is off" is checked.
    • Set "Turn display off after" to a longer duration or "Never" if you prefer.
  2. Use Terminal to Prevent Sleep:

    • You can use the caffeinate command in Terminal to prevent your Mac from sleeping. This command can be tailored to your needs:
      caffeinate -i
      
    • The -i flag will prevent the system from idle sleeping. You can run this command in a Terminal window, and it will keep your Mac awake until you close the Terminal or stop the command.
  3. Third-Party Apps:

    • Consider using third-party applications like Amphetamine or KeepingYouAwake. These apps provide a user-friendly interface to keep your Mac awake under specific conditions.
  4. Security Settings:

    • Ensure that your security settings require a password immediately after the screen saver begins or the display is turned off. Go to System Settings > Security & Privacy > General and set "Require password" to "immediately" after sleep or screen saver begins.

By following these steps, your MacBook should continue running processes even when the screen is locked, while still requiring a password upon resumption.

m7vm7v's avatar
Level 51

Thank you @laryai. You help is much appreciated. But is seems your knowledge is not up to date with the newest OS as the options are not as described, which is fine as they are similar here and there.

Unfortunately it didn't work. It might be due to the OS update and how the options are applied.

After I've applied the options and then "Lock screen" the processes are still paused.

martinbean's avatar
Level 80

@m7vm7v caffeinate very much works. Even in “up-to-date” versions of macOS. I use it myself regularly, i.e. when I’m encoding videos and don‘t want the process interrupted.

m7vm7v's avatar
Level 51

@martinbean great, thanks. Can you please confirm that I am still able to lock my screen somehow? When I tested and then locked my screen manually / sleep the processes were paused again.

Please or to participate in this conversation.