I'm about to download a 1TB collection of files. It'll take about 7 days.

I want to make sure that my computer doesn't shut down or restart while the download is happening.

  • To prevent the system from going into sleep mode, you should first enter caffeinate in a terminal window. To prevent software updates: System settings > Software update > Further options .. Deactivate the lower 3. An authentication dialog can appear
    – BabyBoy
    Commented Jun 5, 2021 at 8:02

5 Answers 5


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

  • 1
    That does not stop a power failure or a shutdown command
    – mmmmmm
    Commented Jun 4, 2021 at 19:34

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:


while :
    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

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!

  • As already mentioned feedback to other answers should be added as comment there. Also, what is considered "best" may differ from person to person, that's why users here can up/downvote answers they like/don't fully approve. Please have a look at the FAQ to learn more about how this site works and how it differs from the typical discussion forum.
    – nohillside
    Commented Jan 8, 2020 at 6:08
  • Having said that: Your method doesn't protect against somebody running sudo shutdown -r now "Forced reboot" or similar. But then, probably nothing does :)
    – nohillside
    Commented Jan 8, 2020 at 6:09
  • 3
    @nohillside : Of course I realize that different people will have different experiences, which is why I wrote "the best solution* in my experience*". Regarding your second comment, I wouldn't really call that an automatic reboot. My method doesn't "protect" against ctrl+c -> apple -> power off, either. But that's not something I want to protect against, since that's a user input. I.e. a desired shutdown/reboot. The method protects against unexpected reboots due to updates or otherwise software-invoked.
    – Spcaeyob
    Commented Jan 8, 2020 at 10:18

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.

  • As of 2023, the "Advanced" button no longer exists. Look for a little "info" icon to the right of the phrase "Automatic updates". The settings are hidden there now.
    – Jared Beck
    Commented Feb 24, 2023 at 21:59

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.

  • Operation not permitted! Commented Jan 17, 2021 at 17:25
  • 1
    @Mohammad Kanan, At the time this answer was posted, five and a half years ago!, it was applicable to the then current version of Mac OS X and worked as advertised for the intended purpose. It of course is no longer applicable to versions of macOS whose startup disk is read-only! Commented Jan 17, 2021 at 17:36
  • I wonder if you can mount over it e.g. with bind mount / localhost nfs of a duplicate directory (with files renamed)
    – arcyqwerty
    Commented Feb 4, 2021 at 2:31

Another good workaround I discovered is to use Terminal to interrupt the shutdown process:

  1. Open Terminal then go to Terminal menu > Preferences > Shell. Set it to Always ask before closing.
  2. Go to System Preferences > Users & Groups > User account > Login Items.
  3. Add the terminal app and set it to hide.

Whenever the computer attempts to restart, it will hang on the terminal app. It will not force close it and will abort the shutdown instead. Since it is also set to auto-start terminal app silently on login, it will always prompt you whenever you restart. If the shutdown/restart is intentional, you can just hit Close when prompted by Terminal.

This was tested on High Sierra. Not sure if it is also effective for newer mac os and/or automatic mac os updates.

  • That does not deal with a shutdown command or a power or network problem
    – mmmmmm
    Commented Jun 4, 2021 at 19:36
  • 1
    @mmmmmm I don't think any software could stop a power problem! What sort of network problem would cause a shutdown?
    – grg
    Commented Jun 5, 2021 at 9:47

You must log in to answer this question.

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