How to prevent macOS from terminating programs after inactivity.

Joined
Sep 13, 2017
Messages
9
Reaction score
0
Points
1
After some time of inactivity macOS kills running programs, how do i avoid that? For example before i went to bed i had a terminal opened and a command running: "yes > /dev/null". When i woke up the command was no longer running, instead i saw "[Restored 2 Nov 2018 at 07:19:37]"
Same happens with XCode and it's running programs.

My OS settings:
Turn display off after: Never
Start screensaver: after 20 minutes
Prevent computer from sleeping automatically when the display is off: Checked
Put hard disks to sleep when possible: No
Enable Power Nap: No
Require password after sleep or screensaver begins: No
Log out after 60 minutes of inactivity: No

I can't find a way to prevent macOS from killing programs after extended period of inactivity like that... I tried to disable every possible setting that might be related this. No luck. Help.

It might be related to Mojave (not sure), I did not have such problems before with previous version. Or maybe i accidentally misconfigured something. No idea. Any help is welcome.

It seems that there's no "Computer sleep" slider on my OS's energy saver panel. I bet it has something to do with it. Was it recently removed? Where and how can i change it?
 
Last edited:
Joined
Nov 28, 2007
Messages
25,564
Reaction score
486
Points
83
Location
Blue Mountains NSW Australia
Your Mac's Specs
Silver M1 iMac 512/16/8/8 macOS 11.6
Are you sure there is no 'Energy Saver' panel?

Put the pointer over the little box at the top with three rows ofd four dots, click and hold and all then options come up. Maybe 'Energy Saver' is there and you had not moved this into the visible panels. Have never seen this but then again for mine I would not leave a terminal command running overnight.
 
OP
G
Joined
Sep 13, 2017
Messages
9
Reaction score
0
Points
1
Are you sure there is no 'Energy Saver' panel?

Put the pointer over the little box at the top with three rows ofd four dots, click and hold and all then options come up. Maybe 'Energy Saver' is there and you had not moved this into the visible panels. Have never seen this but then again for mine I would not leave a terminal command running overnight.

There is "Energy Saver" panel. There's no "Computer sleep" slider in it.

Did some research on this topic, it turns out the programs aren't actually killed, after executing "ps aux | grep -i MyProgram" i can find my program running. Just the applications like "Terminal" or "XCode" are loosing a connection to it and programs end up running in the background.
After googling a bit i found a command: "sudo pmset -a disablesleep 1". Will test it tomorrow. Hope it works.
 
Joined
Jan 1, 2009
Messages
15,507
Reaction score
3,866
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 15 Pro, plus ATVs, AWatch, MacMinis (multiple)
In Mojave, the Power panel has changed a bit, I think. What I see is on Power Adapter, there is a "Prevent computer from sleeping automatically when the display is off." But there is only one slider, for "Turn display off after." On Battery, that "Prevent..." is not there. So I guess what the options should be is to set the display for whatever you want, but then make sure that the "Prevent computer...." box is checked. It may be that setting the display to Never somehow is messed up and that the "Prevent..." then doesn't get read. So I would test by setting the display off function to something other than Never to see if that sorts it out. If it does, then you can submit a bug report to Apple about the phenomenon.
 
OP
G
Joined
Sep 13, 2017
Messages
9
Reaction score
0
Points
1
It was checked, also double/triple checked that it's checked, mentioned in OP:

Prevent computer from sleeping automatically when the display is off: Checked
 
Joined
Jan 1, 2009
Messages
15,507
Reaction score
3,866
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 15 Pro, plus ATVs, AWatch, MacMinis (multiple)
Have you tried moving from "Never" to some set time for the screen?
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,765
Reaction score
2,106
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Now that you've figured out how to do what you want to do. Why would you want to keep the machine (and apps) running all the time?
 
OP
G
Joined
Sep 13, 2017
Messages
9
Reaction score
0
Points
1
Now that you've figured out how to do what you want to do. Why would you want to keep the machine (and apps) running all the time?
It's quite irrelevant question. Some programs that i'm running are earning money for me. It's a workstation.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top