5

What is the difference between issuing command shutdown -h now in terminal and doing Shutdown from apple menu?

Using command it's instantly power down the system. But via menu it takes around 30-40 seconds.

Also is it safe to use command shutdown -h now all the time?

6

From the shutdown man page:

 Upon shutdown, all running processes are sent a SIGTERM followed by a
 SIGKILL.  The SIGKILL will follow the SIGTERM by an intentionally inde-
 terminate period of time.  Programs are expected to take only enough time
 to flush all dirty data and exit.  Developers are encouraged to file a
 bug with the OS vendor, should they encounter an issue with this func-
 tionality.

So from what I understand, processes may be killed before they have properly cleaned up.


From the launchctl man page:

  reboot [system|userspace|halt|logout|apps|reroot <mount-point>]
              Instructs launchd to begin tearing down userspace. With no argu-
              ment given or with the system argument given, launchd will make
              the reboot(2) system call when userspace has been completely
              torn down. With the halt argument given, 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 ini-
              tiating a reboot.

This is what I think shutting down via the menu does, it is better as it ensures that all userland processes are exited cleanly before halting/rebooting the system.


I would be tempted to say that the launchctl method is better, and the shutdown -h now method could possibly result in some oddities should a process be killed before properly cleaning itself up.

  • And if any of your apps have unsaved changes (e.g. a document you've edited but not saved), shutdown -h will not give you a chance to save them. Not sure about the launchctl method... – Gordon Davisson Aug 12 '15 at 4:36

You must log in to answer this question.

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