找回密码
 注册
查看: 1851|回复: 0

linux系统shutdown命令

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-9-7 15:00:39 | 显示全部楼层 |阅读模式
1:立即、马上关闭Linux系统,其中 now 相当于时间为 0 的状态' ^1 v- q  t7 x2 _5 a) o7 t' x
[root@db-server ~]# shutdown -h now6 C3 H; ~0 T' k' G9 v+ V5 [" z" p4 i
  b7 E1 }2 G1 J* ?0 K$ [

  l) d% [$ D; J: X' O* c% ?2:系统2分钟后重新启动,其中+m表示几分钟后关机或开机。8 i6 E- h. J- q, H1 a/ i# ~
[root@db-server ~]# shutdown -r +2
, l0 d* g0 m" S4 O6 W7 w$ Z7 Z: }- |. q+ z3 O' Q, o

, T( n; D( M5 W4 o. e3:设置系统在那个时间点关机) X4 V+ |% L9 H
[root@db-server ~]# shutdown -h 12:00
9 u$ X# W. r6 C4 u) U或后台执行 ; S4 H) D2 v( m4 a8 ^) |
[root@db-server ~]# shutdown -h 12:00 &2 a, n, e9 t1 R0 h- L# m% v  c
最好是使用命令&将关机命令至于后台处理。不影响当前其它操作。# R9 h, F1 I& Q' Q  |
设置多久时间后执行shutdown命令。时间参数有hh:mm或+m两种模式。hh:mm格式表示在几点几分执行shutdown命令。
+ z/ K  F- d3 Z' |4 N' w# X例如 “shutdown 10:05”表示将在10:05执行shutdown.+m表示m分钟后执行shutdown.比较特别的用法是以now表示立即执行shutdown. 值得注意的是这部分参数不能省略。
" B; Z* `' l  T另外,需要注意如果现在已经22:30,你执行了shutdown -h 22:00 & 那么第二天才会关机。
; C- q5 S7 H. ?+ u
/ N: o& G$ b! Z3 ~7 p4:查看后台是否执行shutdown命令
; h! i3 _' t5 Q9 D) g
: J% L) E. y7 G7 A" N6 m; y4 c) {[root@db-server ~]# jobs
; M, _$ d  w6 O
# c. k. Q8 l2 {- R( O& [$ I[1]+ Running shutdown -h 08:00 &- k, J. k' n2 v6 e
) Z/ |- l% U% Z
5:取消shutdown命令执行7 t  q7 k0 i- C8 n( q2 p
执行了下面命令让Linux在12:30关机,但是如果发现这个时间点不合适,那么可以使用CTRL+C取消。, G7 b# D0 l$ x; N# {- `
  I. y) G: g1 _: E  O9 h
[root@db-server ~]# shutdown -h 12:30
0 A7 o, Y1 Y$ W7 W- d4 A5 gShutdown cancelled.
, }. a$ O$ B4 M: \" j, E[root@db-server ~]#
: L* m4 L) i( R  d# L; q也可以在另外一个命令窗口执行下面命令0 L. [+ m. d& ~, C9 L1 I- \5 `
[root@db-server ~]# shutdown -c: s6 E7 H8 G; f

; g8 G: Q9 L& t  t6:向所有登录的用户发出信息6 P' N4 u9 Z$ N" S% `
[root@db-server ~]# shutdown -k "now"/ \* a. f. g0 V0 E* Z  P& Z3 }. O
Broadcast message from root (pts/2) (Sat Jan 10 20:09:14 2015):. r) ?6 s4 w) ?- `; ^( X7 K4 Q
The system is going down to maintenance mode NOW!: R& }* ~/ h. ^8 }
Shutdown cancelled.
, \* D( E  Y, c  m$ c2 P: K9 g另外登录的会话窗口会收到如下信息6 F: b: m1 J4 A/ U3 A( }% Z( \
[root@db-server ~]#
" {6 o+ ?4 c6 b# K  [. o[root@db-server ~]#
6 r: e; O0 \- r" i2 a  `0 cBroadcast message from root (pts/2) (Sat Jan 10 20:11:34 2015):
- x/ D+ u$ d$ h, w7 ^. r. ^The system is going down to maintenance mode NOW!* Q4 D5 M" q8 m; |1 l
一般使用下面语法,如下所示7 q' g6 [' I7 H* @, u; A. U
[root@db-server ~]# shutdown -k now "The Server will shutdown now
$ \, l" a* a: ]Broadcast message from root (pts/1) (Sat Jan 10 20:14:54 2015):
2 |, R2 Q) o, H$ V/ z. T! sThe Server will shutdown now # m  ~9 i: G0 [$ `2 C, V9 l
The system is going down to maintenance mode NOW!3 h8 y5 g/ w: l8 z1 i% W
Shutdown cancelled.; \( z0 Q; h$ \5 y( g$ N) u

2 h" D2 j* G5 p; C6 W( A0 p% E2 a7 b# ?9 ~
7:重新启动时不进行磁盘检测
) Q) a( U) Q7 d, v[root@db-server ~]# shutdown -fr now- O7 u( E) M2 h3 q& N$ B6 x: N7 [
Broadcast message from root (pts/1) (Sat Jan 10 20:23:59 2015): ' A( P: K9 X+ X3 B, y% @
The system is going down for reboot NOW!; j+ r8 i- @3 O% A

2 Z: O0 ~# P/ x
$ W* K$ u7 t8 k8:在多少秒后关闭系统并给用户发送提示信息
" E7 {1 Q; `! K[root@db-server ~]# shutdown -t 10 -h now "System will shutdown 10 sencond later"
. Z9 d8 Y$ j' nBroadcast message from root (pts/1) (Sat Jan 10 20:33:36 2015): , d& \0 z/ `9 M7 q- B' @# ?$ b
System will shutdown 10 sencond later - B2 Y' P% w( Y; {( q
The system is going down for system halt NOW!
8 U/ c. Y7 x+ r5 m& Y) {( K- B  ]1 n
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 02:10 , Processed in 0.014887 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表