1

Situation: a mac running 10.14, accessed from a Windows laptop via TeamViewer remote desktop software.

Problem: sometimes apps will prevent shutdown. "Xcode interrupted shutdown" or similar. Once every 1-3 weeks.

Because the TeamViewer app on the mac quits successfully — terminating the network connection before the "$app interrupted shutdown" message is shown — I never see this message myself and only know about it because coworkers with physical access report it to me when I ask for their help.

When the mac fails to shut down, the automatic boot-up the next morning also never runs, therefore the TeamViewer app on the mac never re-opens, therefore I can't connect to it remotely the next day.

Question: Is there some way to force the mac to shutdown, no matter what state it is in, even when apps interrupt the process?

(Software solutions only — while a timer switch that periodically cuts power would work, I don't want to risk physical damage from regular power interruptions).

3

Have you tried to execute shutdown from Terminal:

sudo shutdown -h 2011032000 "Shutting down at 8:00pm tonight"

You can specify the precise time, using the yymmddhhmm format, and using a 24-hour clock for the time.

At least it doesn't ask me to quit or save any running program. It will simply quit anything running in.

You can make automator script to execute too if this helps for your requirement.

| improve this answer | |
  • Have you tested with apps known to prevent shutdown, like Photoshop? if it has an open unsaved document it will always demand an answer before it will quit. For most Apple apps & many others this doesn't apply as they willl just restore to the same point at which they quit. – Tetsujin Nov 3 at 12:08
  • I have tested it with atleast third party applications like MS Outlook unsaved draft email, MS Excel unsaved sheet, VS Code Editor and other my daily tools. I am using this line from terminal for several time but haven't tested with Photoshop. We will loose all unsaved data that's for sure with this line. – Udhy Nov 3 at 12:32
  • 1
    @Tetsujin From man shutdown: Upon shutdown, all running processes are sent a SIGTERM followed by a SIGKILL. Neither Photoshop nor any other application can protect against a SIGKILL. – nohillside Nov 3 at 12:38
  • 2
    In the OP's case, and assuming that a daily reboot is expected to happen anyway, I would just set up a daily cronjob enforcing a shutdown about an hour before the automatic boot-up. – nohillside Nov 3 at 12:40
  • 1
    @nohillside A well written app should save its state on a SIGTERM - However not may are – mmmmmm Nov 3 at 14:48
1

Power Manager

Power Manager can be used to remotely shut down a Mac. You can do this to a schedule or on-demand through a secure remote connection.

Applications that traditionally block log out are not a problem for Power Manager. Power Manager works through a series of steps to safely shut down a Mac; these steps are:

  1. Running applications are sent a friendly quit request.
  2. Running applications are given time to quit.
  3. If an application has not quit in time, the application is force quit.
  4. With all the applications quit, the user is logged out.
  5. Once all the users are logged out, Power Manager then asks macOS to shut down.

I am an engineer working on Power Manager, so feel free to ask technical questions or get in touch via the company's support e-mail address.

| improve this answer | |
0

I cannot test this with TeamViewer, but I managed to get it to work over Apple Remote Desktop. I was connected to a Mac I could also physically watch whilst I was doing this remotely.
I did it all via the GUI for best emulation of what may happen over Teamviewer.

You need the Fast User Switching menu item enabled on the remote Mac - System Prefs > Users & Groups > Login Options
Switch to another admin user. Sign in.
From the Apple menu, select Shut Down [I used Restart for convenience but I'm sure there's no real difference]
The following message appears…

Restarting my cause other users logged into this computer to lose unsaved changes

Restarting my cause other users logged into this computer to lose unsaved changes

Enter your admin credentials & hit Restart/Shut Down as appropriate.
This will [seemingly gracefully] 'force' quit any app that demands an answer before it would normally quit.

I tested with a Photoshop document with unsaved changes. This is normally guaranteed to prevent Shut Down. There was no noticeable delay at all, the Mac shut down as though everything had just quit as normal.

Note: The unsaved changes were indeed lost after reboot.

| improve this answer | |

You must log in to answer this question.

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