【问题标题】:What is the difference between `$/sbin/restart nginx` and `$service nginx restart`?`$/sbin/restart nginx` 和 `$service nginx restart` 有什么区别?
【发布时间】:2020-09-08 12:32:33
【问题描述】:

我想在增加/etc/security/limits.d/nginx.conf 中的文件描述符限制后重新启动nginx,我需要重新启动 nginx 进程才能使更改生效。

我应该使用$/sbin/restart nginx 还是$service nginx restart,有什么区别?


参考/sbin/restart是什么:

$ /sbin/restart --help
Usage: restart [OPTION]... JOB [KEY=VALUE]...
Restart job.

Options:
  -n, --no-wait               do not wait for job to restart before exiting
      --system                use D-Bus system bus to connect to init daemon
      --dest=NAME             destination well-known name on system bus
  -q, --quiet                 reduce output to errors only
  -v, --verbose               increase output to include informational messages
      --help                  display this help and exit
      --version               output version information and exit

JOB is the name of the job that is to be restarted, this may be followed by zero or more environment variables to be defined in the job after
restarting.

The environment also serves to distinguish between job instances, and thus decide which of multiple instances will be restarted.

Report bugs at <https://launchpad.net/upstart/+bugs>

【问题讨论】:

    标签: linux nginx amazon-linux


    【解决方案1】:

    sbin/nginx你直接向nginx发送命令。

    服务也是如此(查看屏幕截图):

    附:在我的 ubuntu 服务器中,我没有 /sbin/restart,如果你有它,请尝试做 cat /sbin/restart

    【讨论】:

    • 谢谢,我在问题中添加了/sbin/restart 帮助。我很困惑,因为它谈论的是jobs,这和进程一样吗,和服务一样吗?
    • 我第一次看到/sbin/restart,谷歌搜索并没有给我任何信息。所以如果你想重新启动 nginx 使用:service nginx restartsystemctl restart nginx - /sbin 文件夹似乎令人毛骨悚然(因为init 脚本在那里)所以我不认为你应该用户/sbin/restart
    • 也许它特定于 Amazon Linux。例如,AWS 推荐 /sbin/restart nodejs 重启节点。 github.com/awsdocs/elastic-beanstalk-samples/blob/master/…
    • 好吧,他们没有提到将它用于 nginx。所以我想了解其中的区别。所有命令都重新启动 nginx,但我不确定每个命令是否都同样优雅地执行。
    猜你喜欢
    • 1970-01-01
    • 2017-12-06
    • 2015-05-29
    • 1970-01-01
    • 2015-10-12
    • 1970-01-01
    • 2019-05-29
    • 2021-04-13
    • 2014-02-24
    相关资源
    最近更新 更多