My MacBook Pro is running, ssh works fine, but the screen does not respond anymore.

The screen is frozen like the ice of Antarctica. The mouse does not move on the screen. The time of the clock does not change.

The Caps Lock light of the keyboard is responding.

Can you help me to get my screen responding again, please?

What I need is simply having my screen responding, in order to use my Mac and to continue what I was doing.

  • 1
    This is great question. I've been in this situation so many times - the GUI becomes frozen, but the SSH works fine - and I stiil don't know the way to restart the GUI without rebooting the whole machine. George, the question is not about what caused the freeze, it is about how to recover from it. – Sergei May 29 '14 at 16:12

Since you can ssh into the box, you can start killing processes one by one and eventually you will either reboot the box or free up the item that's holding the CPU / GUI frozen.

I would probably do these things in order of severity:

  1. Start a time machine backup before killing anything tmutil startbackup --block --rotation
  2. If I don't care to save work (since this kills all apps abruptly) - kill the loginwindow process and log back in.
  3. If I do care to save some work, kill all user processes not belonging to the user that needs to save work.
  4. Then kill all user processes that don't need work saved. (Apps and such)
  5. Then use AppleScript to tell each app that needs to save work to quit. (assuming the GUI isn't responsive at this point)

osascript -e 'quit app "Take Five" '

At this point, you'll either need to list the specific apps that you need to save work and ask if there are any ways to force a save (perhaps they use autosave and will recover all work anyhow) or just issue a restart / reboot command and get on with using the machine and recover what you can from your last backup.

  • In step 2. I think that killing loginwindow would quit all my session. – Nicolas Barbulesco Jun 24 '14 at 22:00
  • 1
    Yes - hence the warning if you don't care to save your work. I'll beef that up explicitly ;-) – bmike Jun 24 '14 at 22:38
  • 1
    osascript works fine from local terminal session (things like osascript -e 'tell application "Sublime Text" to activate ' -e 'tell application "System Events" to keystroke "s" using command down'), but if ran from ssh, even your quit app example fails with Application isn’t running. (-600). I can't get osascript to interact with any apps from ssh so far. More weirdness: osascript -e 'tell app "system Events" to activate' works from REMOTE session, fails from local session (Application isn’t running) – Sergei Jun 25 '14 at 12:03
  • Dang - I may have to dig to find how to attach osascript to a log in session (or perhaps the process needed is the one blocking your session?) it might be a lost cause either way... – bmike Jun 25 '14 at 12:14
  • @Sergei - Very strange. Enabling remote Apple Events may help. – Nicolas Barbulesco Jun 25 '14 at 13:58

Killing WindowServer will get you out of most situations, but all GUI apps will die and restart with it.

The solution is to save data in all apps that don't do it automatically using Applescript
ps ax | grep -i appname
osascript save.scpt 6546, where 6546 is the PID of your app

The script will press Cmd+S and (optionally) Enter

on run argv
tell application "System Events"
    set theprocs to every process whose unix id is item 1 of argv
    repeat with proc in theprocs
        set the frontmost of proc to true
        delay 1
        keystroke "s" using command down
        delay 1
        # key code 36 # Enter
    end repeat
end tell
end run

P.S. This works from SSH session for apps like Sublime Text, but I can't figure out the way to tell the app to quit gracefully. It's either kill or reboot. The latter should take care of apps that support "Resume" feature.


I know this is a late answer, and you may have already given up. I did a quick search and found that you can enable screen sharing (VNC) via SSH without AppleScript.

sudo  /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes \
-clientopts -setvncpw -vncpw mypasswd -restart -agent -privs -all

I copied that command verbatim from here. You want to omit the restart flag, I believe. Connect to your machine with a VNC client, save all of your work, and reboot the machine.

  • I had tried to remotely enable VNC — to no avail. Does this command launch VNC just once (until shutdown or restart) ? Or does this command enable VNC permanently ? I think that the answer is permanently. – Nicolas Barbulesco Jun 26 '14 at 21:24

You must log in to answer this question.

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