Linux 服务重载和服务重启有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7374181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 06:08:01  来源:igfitidea点击:

What is the difference between, service reload and service restart?

linux

提问by Wiredguy

What the difference between services [name] reload and service [name] restart? actually, they same.. well, what recommand to use?

services [name] reload 和 service [name] restart 有什么区别?实际上,它们相同……嗯,使用什么推荐?

回答by Kevin Lacquement

Reload will tell the service to reload its configuration files, but keep the same process running. Restart tells it to shut down entirely, then restart.

重新加载将告诉服务重新加载其配置文件,但保持相同的进程运行。重新启动告诉它完全关闭,然后重新启动。

回答by Ignacio Vazquez-Abrams

restartshuts the service down and then starts it up again, whereas reloadinstructs the daemon to reload its configuration. You use whichever is appropriate for your situation.

restart关闭服务然后再次启动它,同时reload指示守护进程重新加载其配置。您使用适合您情况的任何一种。

回答by Michael Berkowski

Some services which support the reloadcommand can reload their configuration without fully shutting down and starting up again. Postfix does this, as does Apache. It is very useful if you need to make configuration changes to a live server without incurring even a few seconds of downtime.

一些支持该reload命令的服务可以重新加载其配置而无需完全关闭并再次启动。Postfix 这样做,Apache 也是如此。如果您需要对实时服务器进行配置更改而不导致几秒钟的停机时间,这将非常有用。

回答by bdonlan

Generally speaking, restartwill terminate the service in question and restart it; reloadwill only reload the configuration file.

一般来说,restart会终止有问题的服务并重新启动它;reload只会重新加载配置文件。

Since reloadonly reloads the config, it will cause less disruption to existing activities and currently open connections; users might not even notice that it was run. However, depending on what server we're talking about, some options may not be changeable using reload; and if the server is using too much memory, etc, it may be necessary to use restartto force it to start from a clean slate.

由于reload仅重新加载配置,因此对现有活动和当前打开的连接造成的干扰较少;用户甚至可能不会注意到它已运行。但是,根据我们所谈论的服务器,某些选项可能无法使用reload; 如果服务器使用太多内存等,可能需要使用restart强制它从干净的平板启动。

Further, note that not all services support reload; all services support restart.

此外,请注意并非所有服务都支持reload;所有服务支持restart