5 ways to reboot/logout/shutdown much faster

315 阅读1分钟

syntax

launchctl reboot [system|userspace|halt|logout|apps]

restart

  • sudo launchctl reboot or sudo launchctl reboot system launchd will make the reboot(2) system call when userspace has been completely torn down. The same as the restart operation from the Apple menu.
  • sudo launchctl reboot userspace With the userspace argument given, launchd will re-exec itself when userspace has been torn down and bring userspace back up. This is useful for rebooting the system quickly under conditions where kernel data structures or hardware do not need to be reinitialized. A little faster restart but there are sometime bugs, I think, such as missing external disk or reverting the default shell from zsh to bash.

shutdown

launchctl reboot halt

launchd will make the reboot(2) system call when userspace has been completely torn down and pass the RB_HALT flag, halting the system and not initiating a reboot. The same as the Shut Down operation from the Apple menu.

logout

launchctl reboot logout

launchd will tear down the caller's GUI login session in a manner similar to but much faster than a logout initiated from the Apple menu. Only use it when you know you have no unsaved data in your running apps.

Terminate all user apps

launchctl reboot apps

launchd will terminate all apps running in the caller's GUI login session that did not come from a launchd.plist(5) on-disk. Apps like Finder, Dock and SystemUIServer will be unaffected. It's very fast but still no confirmation to unsaved data.