Linux Graceful Shutdown

linux

I have heard that "shutdown -h now" is not a graceful shut down command because it does something akin to "kill -9" for all processes, as opposed to "kill -15".

Is this true, and if so, what is a more graceful way of shutting down to ensure everything has time to clean up after its self?

P.s. Using CentOS, Ubuntu, and Debian mainly.

Best Answer

shutdown -h now will call /etc/rc.d/rc or /etc/init.d/rc. The rc script will call the kill scripts for the new runlevel (0 for -h, 6 for -r), followed by any start scripts.

You'll see S30killprocs or S00killall or something like that depending on your distro. This comes after all the kill scripts have been called to attempt to stop each service gracefully in turn. It will try kill -15 first, followed by kill -9.

Short answer: shutdown -h now or shutdown -r now are graceful. halt and reboot used to be non-graceful, but they will just call shutdown for you unless you use the -f option.