kafka 命令重新启动_命令行基础知识:关闭和重新启动

本文介绍了在命令行中如何优雅地关闭和重启服务器,特别是针对Unix-like系统如Linux。`shutdown`和`reboot`命令分别用于计划关机和立即重启,而`wall`消息则通知所有登录用户。了解这些命令对于在不同主机提供商之间切换和管理远程服务器至关重要。
摘要由CSDN通过智能技术生成

kafka 命令重新启动

When you’re in the same room as a server, shutting it down or rebooting it is simple. You could hold the power button or even unplug the whole machine. Not only are these solutions inelegant, they have the potential to corrupt your data and potentially damage your hardware! They also don’t work when you’re logged into your favorite remote server.

当您与服务器位于同一房间时,关闭或重新启动它很简单。 您可以按住电源按钮,甚至拔下整个机器的电源。 这些解决方案不仅笨拙,而且还可能破坏您的数据并可能损坏您的硬件! 当您登录到喜欢的远程服务器时,它们也不起作用。

Depending on your hosting provider, you very well may have a nice GUI interface at your disposal, completely with a shiny red button to shutdown or reboot the machine. It’s a sufficient solution, but doesn’t necessarily scale across different hosting providers.

根据主机提供商的不同,您可能会拥有一个不错的GUI界面,完全带有一个闪亮的红色按钮来关闭或重新启动计算机。 这是一个足够的解决方案,但不一定跨不同的托管服务提供商扩展。

Knowing how to do things on the command-line allows you to be as stack agnostic as possible. You can switch easily between hosting providers and always have the same consistent set of tools at your disposal. This flexibility comes in extra handy when you’re working with a brand new stack that you’re not familiar with.

知道如何在命令行上执行操作可以使您尽可能地与堆栈无关。 您可以在托管服务提供商之间轻松切换,并始终拥有相同的一致工具集。 当您使用不熟悉的全新堆栈时,这种灵活性特别方便。

入门 (Getting started)

The commands discussed in this article, shutdown and reboot do exactly as their names imply. They will shut down or reboot your machine. Because these are somewhat destructive commands, if you run them locally, be ready for your system to system to shut down or reboot.

本文讨论的命令, shutdownreboot与它们的名称所暗示的完全相同。 他们将关闭或重新启动计算机。 因为这些命令具有破坏性,所以如果在本地运行它们,请准备好使系统关闭或重新引导。

Using a remote development or staging server running a Unix-like operating system (like Linux) would be an ideal scenario. Because you will in fact take your server off line with these commands, I wouldn’t recommend running them on a production server unless you really want to reboot the box.

使用运行类似Unix操作系统(例如Linux)的远程开发或登台服务器将是理想的方案。 因为实际上您将使服务器与这些命令脱钩,所以除非您确实要重新启动该框,否则我建议您不要在生产服务器上运行它们。

The following commands will more than likely require elevated super-user privileges to run. If you receive an error about a command not being found, just try it again with sudo.

以下命令很可能需要提升的超级用户特权才能运行。 如果收到关于找不到命令的错误,请使用sudo再次尝试。

If you don’t have super-user privilege on the machine you’re on, you more than likely won’t be able to shut it down or reboot it.

如果您所在的计算机没有超级用户特权,则很有可能将其关闭或重新启动。

关机 (Shutting down)

Shutting down a system can be done with the shutdown command, in it’s simplest form, without any arguments:

可以使用shutdown命令以最简单的形式关闭系统,而无需任何参数:

$ shutdown # Graceful shutdown in 1 minute

Without any arguments, the shutdown command will schedule the shutdown for a minute out from the current time. Because it’s scheduled in the future, you have a window of opportunity to cancel the shutdown by way of the -c argument:

如果不带任何参数, shutdown命令将安排关机时间比当前时间晚一分钟。 因为它是将来计划的,所以您有机会通过-c参数取消关闭:

$ shutdown -c # Cancel a scheduled shutdown

Crisis averted!

避免危机!

You may have noticed that a broadcast message was issued when you ran the first shutdown command. That’s the wall message, and it’s issued to all of the users that are currently logged into the system.

您可能已经注意到,当您运行第一个shutdown命令时,发出了一条广播消息。 这是墙壁消息,它会发给当前登录到系统的所有用户。

The time of the shutdown can be scheduled, as well as the content of the wall message that is presented to your users:

可以安排关闭时间以及显示给您的用户的挂墙消息的内容:

$ shutdown now "Cya later alligator" # Immediately shut down
$ shutdown +5 "Cya later alligator"  # Shutdown in 5 minutes

Because the arguments are passed in order and without additional --flags to indicate what the values are, they must be passed in a specific order. That means you can’t customize the wall message without also specifying a time.

因为参数是按顺序传递的,并且没有附加的--flags来指示值是什么,所以必须按特定的顺序传递它们。 这意味着您不能在不指定时间的情况下自定义留言。

重新启动 (Rebooting)

If you are just looking for a quick and easy way to reboot a server, the reboot command is about as easy as it comes:

如果您只是在寻找一种快速轻松地重启服务器的方法,那么reboot命令就和它一样简单:

$ reboot    # Graceful restart
$ reboot -f # Forceful, like holding the power button

In tune with the Unix Philosophy, the reboot command does what it’s name implies and not much else.

Unix Philosophy协调reboot命令执行了其名称所隐含的内容,仅此而已。

The shutdown command on the other hand, actually does a bit more than the “shutdown” name infers, by allowing you to use it to reboot a machine as well as shut it down.

另一方面, shutdown命令实际上比“ shutdown”名称推断的功能要多得多,它允许您使用它来重新启动计算机以及将其关闭。

Why this is important is that while the reboot command is quick and gets the job done, using the shutdown command to restart your machine gives you the added benefit of being able to schedule things as well as edit the wall message.

之所以如此重要,是因为尽管reboot命令很快并且可以完成工作,但是使用shutdown命令重新启动计算机可以为您带来更多好处,使您能够安排工作以及编辑留言。

To tell the shutdown command to reboot instead of just shutting down, pass in the -r or --reboot argument, along with any other options:

要告诉shutdown命令重新启动而不只是关闭,请传递-r--reboot参数以及任何其他选项:

$ shutdown --reboot                       # Reboot in 1 minute
$ shutdown -r now "After while crocodile" # Immediately reboot
$ shutdown -r +5 "After while crocodile"  # Reboot in 5 minutes

Similar to how we canceled a full shutdown earlier, another added benefit over reboot is that you can also cancel a reboot via shutdown by calling it again with the -c argument:

与我们之前取消完全关闭的方式类似,与reboot ,另一个额外的好处是,您还可以通过使用-c参数再次调用重新启动来通过shutdown来取消重新启动:

$ shutdown -c # Cancel a scheduled shutdown (or reboot!)

翻译自: https://www.digitalocean.com/community/tutorials/workflow-command-line-basics-shutdown-reboot

kafka 命令重新启动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值