Table of Contents
cmd shutdown命令:关机,重启,休眠
显示shutdown命令语法
Home Operation and Maintenance Linux Operation and Maintenance How to use shutdown command to shut down Linux

How to use shutdown command to shut down Linux

Jun 17, 2021 am 11:53 AM
linux shutdown

方法:1、“shutdown -s -t 秒数”定时关机;2、“shutdown -p”或者“shutdown -s -t 0”命令立即关机;3、“shutdown -r -t 秒数”定时重启;4、“shutdown -h”设置休眠。

How to use shutdown command to shut down Linux

本教程操作环境:Red Hat Enterprise Linux 6.1系统、Dell G3电脑。

cmd shutdown命令:关机,重启,休眠


一段时间后关机:

shutdown -s -t 秒数效果是倒计时到该秒数后关机,例如shutdown -s -t 3600就是3600秒后关机,也就是一小时后关机

立即关机命令:

shutdown -p关闭本地计算机,效果是马上关机,而不进行倒计时
也可以使用shutdown -s -t 0设置0秒后关机,也就是立即关机的意思。

一段时间后重启

shutdown -r -t 秒数,效果是倒计时该秒数后重启,例如shutdown -r -t 0倒数0秒后重启,也就是立即重启的意思,如果没有加-t参数则会倒计时默认的秒数后关机,一般是一分钟。

休眠命令

shutdown -h,这条指令让计算机休眠,也就是完全断电,但是会保存当前电脑的状态,下次启动时这些打开过的程序都还在。类似虚拟机的挂起功能。

显示shutdown命令语法


遇到命令不懂的时候,一般会去网上搜索,但是我发现网上的资料都介绍的都全,其实,最应该做的应该是直接在cmd中查看,官方的介绍文档。
输入shutdown -help显示shutdown指令的用法

用法: 

shutdown [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f]   [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
Copy after login
    没有参数   显示帮助。这与键入 /? 是一样的。
    /?         显示帮助。这与不键入任何选项是一样的。
    /i         显示图形用户界面(GUI)。
               这必须是第一个选项。
    /l         注销。这不能与 /m 或 /d 选项一起使用。
    /s         关闭计算机。
    /sg        关闭计算机。在下一次启动时,
               重启任何注册的应用程序。
    /r         完全关闭并重启计算机。
    /g         完全关闭并重新启动计算机。在重新启动系统后,
               重启任何注册的应用程序。
    /a         中止系统关闭。
               这只能在超时期间使用。
               与 /fw 结合使用,以清除任何未完成的至固件的引导。
    /p         关闭本地计算机,没有超时或警告。
               可以与 /d 和 /f 选项一起使用。
    /h         休眠本地计算机。
               可以与 /f 选项一起使用。
    /hybrid    执行计算机关闭并进行准备以快速启动。
               必须与 /s 选项一起使用。
    /fw        与关闭选项结合使用,使下次启动转到
               固件用户界面。
    /e         记录计算机意外关闭的原因。
    /o         转到高级启动选项菜单并重新启动计算机。
               必须与 /r 选项一起使用。
    /m \\computer 指定目标计算机。
    /t xxx     将关闭前的超时时间设置为 xxx 秒。
               有效范围是 0-315360000 (10 年),默认值为 30。
               如果超时时间大于 0,则默示为
               /f 参数。
    /c "comment" 有关重新启动或关闭的原因的注释。
               最多允许 512 个字符。
    /f         强制关闭正在运行的应用程序而不事先警告用户。
               如果为 /t 参数指定大于 0 的值,
               则默示为 /f 参数。
    /d [p|u:]xx:yy  提供重新启动或关闭的原因。
               p 指示重启或关闭是计划内的。
               u 指示原因是用户定义的。
               如果未指定 p 也未指定 u,则重新启动或关闭
               是计划外的。
               xx 是主要原因编号(小于 256 的正整数)。
               yy 是次要原因编号(小于 65536 的正整数)。
Copy after login

此计算机上的原因:

(E = 预期 U = 意外 P = 计划内,C = 自定义)

类别    主要    次要    标题
 U      0       0       其他(计划外)
E       0       0       其他(计划外)
E P     0       0       其他(计划内)
 U      0       5       其他故障: 系统没有反应
E       1       1       硬件: 维护(计划外)
E P     1       1       硬件: 维护(计划内)
E       1       2       硬件: 安装(计划外)
E P     1       2       硬件: 安装(计划内)
E       2       2       操作系统: 恢复(计划外)
E P     2       2       操作系统: 恢复(计划内)
  P     2       3       操作系统: 升级(计划内)
E       2       4       操作系统: 重新配置(计划外)
E P     2       4       操作系统: 重新配置(计划内)
  P     2       16      操作系统: Service Pack (计划内)
        2       17      操作系统: 热修补(计划外)
  P     2       17      操作系统: 热修补(计划内)
        2       18      操作系统: 安全修补(计划外)
  P     2       18      操作系统: 安全修补(计划内)
E       4       1       应用程序: 维护(计划外)
E P     4       1       应用程序: 维护(计划内)
E P     4       2       应用程序: 安装(计划内)
E       4       5       应用程序: 没有反应
E       4       6       应用程序: 不稳定
 U      5       15      系统故障: 停止错误
 U      5       19      安全问题(计划外)
E       5       19      安全问题(计划外)
E P     5       19      安全问题(计划内)
E       5       20      网络连接丢失(计划外)
 U      6       11      电源故障: 电线被拔掉
 U      6       12      电源故障: 环境
  P     7       0       旧版 API 关机
Copy after login

从帮助文档中可以看出

shutdown -h的意思是:休眠本地计算机,执行该指令后计算机会立即休眠。-h参数可以和-f参数一起使用,但是不能和-t参数一起使用。也是就是说shutdown -h -t 3600这样的用法是错误的。

shutdown -p关闭本地计算机,执行该指令后计算机会立即关闭,也不会等待默认的时间。

shutdown -s表示关闭本地计算机,如果不使用-t参数的话,会倒计时默认的事件后关机,如果使用-t参数的话倒计时设置的时间后关机,例如shutdown -s -t 3600就是3600秒后关机。

shutdown -r表示完全关闭并重启计算机。就理解为重启就行,同样的可以加-t设置倒计时多少时间后重启,例如shutdown -r -t 3600就是倒计时3600秒后重启,而shutdown -r -t 0就是倒计时0秒后重启,也就是立即重启

shutdown -a表示取消关机,或者取消重启。在shutdown -s或者shutdown -r倒计时结束之前执行shutdown -a可以取消关机或者重启操作。

相关推荐:《Linux视频教程

The above is the detailed content of How to use shutdown command to shut down Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

DeepSeek is a powerful intelligent search and analysis tool that provides two access methods: web version and official website. The web version is convenient and efficient, and can be used without installation; the official website provides comprehensive product information, download resources and support services. Whether individuals or corporate users, they can easily obtain and analyze massive data through DeepSeek to improve work efficiency, assist decision-making and promote innovation.

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

There are many ways to install DeepSeek, including: compile from source (for experienced developers) using precompiled packages (for Windows users) using Docker containers (for most convenient, no need to worry about compatibility) No matter which method you choose, Please read the official documents carefully and prepare them fully to avoid unnecessary trouble.

Ouyi okx installation package is directly included Ouyi okx installation package is directly included Feb 21, 2025 pm 08:00 PM

Ouyi OKX, the world's leading digital asset exchange, has now launched an official installation package to provide a safe and convenient trading experience. The OKX installation package of Ouyi does not need to be accessed through a browser. It can directly install independent applications on the device, creating a stable and efficient trading platform for users. The installation process is simple and easy to understand. Users only need to download the latest version of the installation package and follow the prompts to complete the installation step by step.

BITGet official website installation (2025 beginner's guide) BITGet official website installation (2025 beginner's guide) Feb 21, 2025 pm 08:42 PM

BITGet is a cryptocurrency exchange that provides a variety of trading services including spot trading, contract trading and derivatives. Founded in 2018, the exchange is headquartered in Singapore and is committed to providing users with a safe and reliable trading platform. BITGet offers a variety of trading pairs, including BTC/USDT, ETH/USDT and XRP/USDT. Additionally, the exchange has a reputation for security and liquidity and offers a variety of features such as premium order types, leveraged trading and 24/7 customer support.

Get the gate.io installation package for free Get the gate.io installation package for free Feb 21, 2025 pm 08:21 PM

Gate.io is a popular cryptocurrency exchange that users can use by downloading its installation package and installing it on their devices. The steps to obtain the installation package are as follows: Visit the official website of Gate.io, click "Download", select the corresponding operating system (Windows, Mac or Linux), and download the installation package to your computer. It is recommended to temporarily disable antivirus software or firewall during installation to ensure smooth installation. After completion, the user needs to create a Gate.io account to start using it.

Ouyi Exchange Download Official Portal Ouyi Exchange Download Official Portal Feb 21, 2025 pm 07:51 PM

Ouyi, also known as OKX, is a world-leading cryptocurrency trading platform. The article provides a download portal for Ouyi's official installation package, which facilitates users to install Ouyi client on different devices. This installation package supports Windows, Mac, Android and iOS systems. Users can choose the corresponding version to download according to their device type. After the installation is completed, users can register or log in to the Ouyi account, start trading cryptocurrencies and enjoy other services provided by the platform.

gate.io official website registration installation package link gate.io official website registration installation package link Feb 21, 2025 pm 08:15 PM

Gate.io is a highly acclaimed cryptocurrency trading platform known for its extensive token selection, low transaction fees and a user-friendly interface. With its advanced security features and excellent customer service, Gate.io provides traders with a reliable and convenient cryptocurrency trading environment. If you want to join Gate.io, please click the link provided to download the official registration installation package to start your cryptocurrency trading journey.

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

See all articles