|
|
1:立即、马上关闭Linux系统,其中 now 相当于时间为 0 的状态
. R$ ~+ q9 a7 `: d[root@db-server ~]# shutdown -h now
3 F9 U5 S. ^' D4 x
c' t$ n3 r. X. n$ A, P+ c4 u8 |- F
2:系统2分钟后重新启动,其中+m表示几分钟后关机或开机。6 b8 Y# \( z3 n! A
[root@db-server ~]# shutdown -r +21 t2 i# a; `0 C+ b# h: u
& X* F) [' \. _ m0 e/ P. q/ L3 h+ Q! q0 q' W
3:设置系统在那个时间点关机" u& B' q' ~3 W' M9 }
[root@db-server ~]# shutdown -h 12:00
; `1 \9 i3 F' y! h, r* c或后台执行 : a; v4 L: O7 |- X1 W! `: e
[root@db-server ~]# shutdown -h 12:00 &/ E( w8 G! O6 `" r& M
最好是使用命令&将关机命令至于后台处理。不影响当前其它操作。
- P1 \- J, v3 |* K设置多久时间后执行shutdown命令。时间参数有hh:mm或+m两种模式。hh:mm格式表示在几点几分执行shutdown命令。
/ ]' G* R6 l* A% y例如 “shutdown 10:05”表示将在10:05执行shutdown.+m表示m分钟后执行shutdown.比较特别的用法是以now表示立即执行shutdown. 值得注意的是这部分参数不能省略。- i$ k. B8 W: \: z% l
另外,需要注意如果现在已经22:30,你执行了shutdown -h 22:00 & 那么第二天才会关机。
2 u [$ I2 z; s' {" R+ h0 ^
* c& X7 m: \ L. J4:查看后台是否执行shutdown命令
/ P2 ^6 u% q* M6 W. W& @, Y, v4 y6 c }4 D1 s2 O
[root@db-server ~]# jobs) T! e# l& y+ @$ V7 v1 m5 |
: A H0 [7 B2 c
[1]+ Running shutdown -h 08:00 &. F, B) X# f/ R5 d) y* ^$ N o
% u, ^+ H0 h' T# i5:取消shutdown命令执行! S! u; E9 ~) y& C& y J8 H W f
执行了下面命令让Linux在12:30关机,但是如果发现这个时间点不合适,那么可以使用CTRL+C取消。
4 `9 k! s* m0 {& {
6 ^" X! `4 F6 Y* G# C, D1 f) o[root@db-server ~]# shutdown -h 12:30, V; v5 h5 J7 b* G% W6 P# Z8 w
Shutdown cancelled.6 u" R. ^6 ^+ ~( x+ l
[root@db-server ~]#
! _' S7 T$ _4 s0 H- M6 N也可以在另外一个命令窗口执行下面命令
- h7 ^$ s4 C9 K0 s[root@db-server ~]# shutdown -c) D) M0 `7 E0 r, E
& J( n. E) c1 A' ], Z% ?+ ]6:向所有登录的用户发出信息9 I7 O! C5 @ i6 ]8 k, R9 p0 c9 c
[root@db-server ~]# shutdown -k "now": Y6 {2 q2 B0 a: b
Broadcast message from root (pts/2) (Sat Jan 10 20:09:14 2015):
, x2 n" \7 `& G8 N) i$ @The system is going down to maintenance mode NOW! d& g. }9 G. o& y2 r% w9 H0 \. j0 ^* t7 i. p
Shutdown cancelled.
. P, i, ?# ~( J- N另外登录的会话窗口会收到如下信息8 K- r M4 d% ?! u
[root@db-server ~]# 0 E7 A# t0 _' h) F0 G/ K9 Z5 F
[root@db-server ~]# ( |# s; |3 q8 o7 e, C
Broadcast message from root (pts/2) (Sat Jan 10 20:11:34 2015):
+ O3 p, W) V: W7 }5 [' F7 XThe system is going down to maintenance mode NOW!
. v+ I2 @, I" k一般使用下面语法,如下所示/ [4 g+ v/ v& ~# H
[root@db-server ~]# shutdown -k now "The Server will shutdown now
, _% l, S3 d) g% s9 OBroadcast message from root (pts/1) (Sat Jan 10 20:14:54 2015):
0 U! V+ L1 |. n. S: C hThe Server will shutdown now $ X+ T9 b' Y. R0 k
The system is going down to maintenance mode NOW!- b, q% x; o$ c( ~6 i. R7 G$ y
Shutdown cancelled.' `2 b8 S1 N) B( g V$ f T( [
D ~, H" j7 }' _$ I7 z* D
6 D l0 O% I5 n7:重新启动时不进行磁盘检测$ q m3 }1 `; @! s d
[root@db-server ~]# shutdown -fr now" k1 S4 Q! v& u+ d5 ?! X6 P! M
Broadcast message from root (pts/1) (Sat Jan 10 20:23:59 2015):
. C- T' z f8 b E3 ^1 HThe system is going down for reboot NOW!8 E5 t5 K/ P- _& j0 o' n
* T' @' R9 ?/ D0 n# p
3 S0 \) N5 `/ N F' L) T2 Z/ H5 o5 V8:在多少秒后关闭系统并给用户发送提示信息
5 R8 A% C! r8 o- U k# M, e7 N( l' ~# F[root@db-server ~]# shutdown -t 10 -h now "System will shutdown 10 sencond later" 9 [2 u! [& u. ^5 U1 L
Broadcast message from root (pts/1) (Sat Jan 10 20:33:36 2015):
$ J) L' Q0 o+ ]; ]. Q% `( f% bSystem will shutdown 10 sencond later 4 [ q) @2 w4 T# { N7 d
The system is going down for system halt NOW!
E, g) y, c! ^( O+ B2 M |
|