search
HomeOperation and MaintenanceLinux Operation and MaintenanceHow to use shutdown command to shut down Linux

方法: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"]]
    没有参数   显示帮助。这与键入 /? 是一样的。
    /?         显示帮助。这与不键入任何选项是一样的。
    /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 的正整数)。

此计算机上的原因:

(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 关机

从帮助文档中可以看出

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
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
Linux Operations: Utilizing the Maintenance ModeLinux Operations: Utilizing the Maintenance ModeApr 19, 2025 am 12:08 AM

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

Linux: How to Enter Recovery Mode (and Maintenance)Linux: How to Enter Recovery Mode (and Maintenance)Apr 18, 2025 am 12:05 AM

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

Linux's Essential Components: Explained for BeginnersLinux's Essential Components: Explained for BeginnersApr 17, 2025 am 12:08 AM

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

Linux: A Look at Its Fundamental StructureLinux: A Look at Its Fundamental StructureApr 16, 2025 am 12:01 AM

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

Understanding Linux's Maintenance Mode: The EssentialsUnderstanding Linux's Maintenance Mode: The EssentialsApr 14, 2025 am 12:04 AM

Linux maintenance mode is entered by adding init=/bin/bash or single parameters at startup. 1. Enter maintenance mode: Edit the GRUB menu and add startup parameters. 2. Remount the file system to read and write mode: mount-oremount,rw/. 3. Repair the file system: Use the fsck command, such as fsck/dev/sda1. 4. Back up the data and operate with caution to avoid data loss.

How Debian improves Hadoop data processing speedHow Debian improves Hadoop data processing speedApr 13, 2025 am 11:54 AM

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

How to learn Debian syslogHow to learn Debian syslogApr 13, 2025 am 11:51 AM

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools