cheesydoritosandkale cheesydoritosandkale - 1 year ago 89
Swift Question

Is there a way to kill all applications and restart the Mac from the terminal?

Is there a code to run in the terminal that I can use to close all applications and restart the mac? I am currently using "osascript -e 'tell app \"System Events\" to restart" to cause a restart, but it isn't closing the applications. - I need for the code to all be in one command, so I can put it in my code without one canceling out the other.

Answer Source

shutdown will close the apps automatically for you (they may not save their working files, however):


$ sudo shutdown -s now


$ sudo shutdown -r now
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download