How can I keep my Mac from restarting?

Solution 1:

I found a simple solution that's been working for 6 days. Even when I intentionally try to restart my computer as a test, the computer stays on.

What I did is leave a Word Doc open with random text in it, but I didn't save it.

That shows me an error when my computer tries to restart, but it keeps the system on.

This is the error message I get

Solution 2:

I've been trying to accomplish this for quite some time now. I've tried various quick fixes and solutions over the years, none of which have been completely bulletproof, or simply not viable for other reasons.

The reason for all this

Is in 99% of the cases the the os wants to update itself, or system apps. And yes, this despite turning off all settings pertaining to automatic updates in the osx settings. Simply put; Apple wants YOU to always update your mac! IMHO, It's actually a serious issue that apple doesn't want to allow you to be truly in control of your own computers' behavior... But that's another question.

If the OS gets a shutdown/reboot command it will get intercepted, and a user prompt pops up. However sadly, after a while if no user input is given, the computer will still shutdown/reboot. To my knowledge there is no way to completely prevent a reboot of OSX for more than about three months. This is my own experience, anyway.

I am currently using the following solution, which ensures computer stays on for on average 30 days (without any user input, longer if periodically logged into and doing stuff), while still allowing the computer to run screensaver, log out the user, and going into power-saving mode. On demand, I can easily shutdown or reboot the computer using the standard GUI.

I created a bash-script that I saved on the desktop containing the following code:

preventreboot.sh

while :
do
    echo "This BASH-Script prevents automatic reboot of this computer. Press [CTRL+C] or shutdown this terminal to disable and allow automatic reboot."
    sleep 30
done

I use automator to run this script with sudo, in an open terminal window on every startup/login.

I hope this answer helps anyone out there who wants their computer staying on!

Solution 3:

Go to System Preferences —› Security and Privacy —› Advanced..., then uncheck Log out after X minutes of inactivity.

You may need to enter your admin password before you can access this button.

I had a similar question and this fixed it.

EDIT: Also, make sure automatic updates are off. This is in the Software UpdateAdvanced area of System Preferences.

Solution 4:

There may be a piece of commercial software that can intercept a call to reboot/shutdown however I do not know what it is, if it exists. My suggestion, despite you editing out the issue in your OP, is to fix the issue and not look for a workaround!

That said, I give you a workaround that you certainly can test and it should prevent a software call to reboot/shutdown however if the reboot/shutdown is being caused by a hardware issue then this will not work.

You can rename the reboot and shutdown commands in: /sbin

Example in a Terminal:

sudo mv /sbin/reboot /sbin/reboot.ori
sudo mv /sbin/shutdown /sbin/shutdown.ori
  • Note: Once you renamed the reboot and shutdown commands the Apple menu's Reboot... and Shut Down... commands will not work.

If you need to reboot/shutdown, before renaming them back, you'll have to do it from a Terminal using: sudo /sbin/reboot.ori or sudo /sbin/shutdown.ori

The reason you need to do both, even though you say it rebooting not shutting down, is because without knowing the cause of your reboot issue the shutdown command can be use to reboot not just the reboot command, e.g. shutdown -r now will immediately reboot the system.