Is there a way to remotely restart Finder (or wake-up the desktop) from SSH?

Over the last few months I've found my MacBook Pro is getting increasingly unwilling to wake-up if it's gone to sleep of it's own accord - not when I put it to sleep deliberately, but when the machine is left for a while and it eventually goes to sleep itself.

I usually run it with the lid down, with a mini-DVI-connected 'main' monitor and then a USB-connected 'second' monitor. Sometimes no amount of keypressing, gently tapping the power button, disconnecting the external displays and lifting the laptop lid, plugging in USB devices, inserting and ejecting CDs - no amount of any tricks I've tried will 'wake up' the display even though the machine is running (shares available over the network) and I can SSH in.

I can sudo shutdown -r now on the machine, though obviously that's a bit drastic!. It got me wondering if there was any other terminal command I could use to wake-up the Finder (I guess) - it certainly seems that the desktop has gone to sleep and can't be tricked into waking up.

Can the finder be restarted remotely via SSH? If not the finder, does anyone know of any other terminal means of forcing the machine to completely wake-up and return to it's previous state?


Solution 1:

This quits the Finder by sending it the "quit" AppleEvent, which is the same signal the system sends when logging out or restarting via the GUI:

osascript -e 'quit application "Finder"'

I (also) don't think quitting the Finder will fix the wake-from-sleep issue, though.

Solution 2:

You can restart the Finder from SSH using the command:

killall -HUP Finder

I don't think this will help the wake from sleep issue however.

Solution 3:

this answer just cover your last question to wake your system compelety up.
you need do it with Wake-on-LAN protocot, it has sme GUI also.

and also see this example:

Waking up:

There are several utilities for waking up computers over the LAN. A cross-platform utility is WakeOnLAN.You'll need the MAC-address of the computer you want to wake up:

 % wakeonlan XX:XX:XX:XX:XX:XX

To get the MAC-address, ssh into your OS X machine or start the Terminal and

 % ifconfig -a

here is the source.