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.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
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.
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
shutdown commands in:
Example in a Terminal:
sudo mv /sbin/reboot /sbin/reboot.ori sudo mv /sbin/shutdown /sbin/shutdown.ori
shutdowncommands 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
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.
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.
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 : 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!