linux下shutdown,poweroff,reboot,halt学习区别

shutdown主要用于关闭系统

        格式:shutdown [OPTION]...  TIME [MESSAGE]

                                        -r:重启系统,功效与reboot一致

                                        -h:后跟时间  指定关闭时间,关闭行为与halt一致,关机后关闭电源

                                        -P:关闭电源,功效与poweroff一致,关闭电源,不推荐使用,见引用

                                        -c:取消关闭系统行为

                                        -k:只发送提醒信息,并不真正关闭系统

                                        

                            

        例子:           

                    [root@localhost tmp]# shutdown -h 10:10
                    Broadcast message from [email protected]
                    (/dev/pts/1) at 6:23 ...
                    The system is going down for halt in 227 minutes!

                    [root@localhost tmp]# shutdown -h 1010
                    Broadcast message from [email protected]
                    (/dev/pts/1) at 6:23 ...
                    The system is going down for halt in 1010 minutes!

                    [root@localhost tmp]# shutdown -h +10
                    Broadcast message from [email protected]
                    (/dev/pts/1) at 6:26 ...
                    The system is going down for halt in 10 minutes!

                    [root@localhost tmp]# shutdown -r +10 'The system will reboot in 10 min'
                    Broadcast message from [email protected]
                    (/dev/pts/1) at 6:28 ...
                    The system is going down for reboot in 10 minutes!
                    The system will reboot in 10 min 


引用:http://blog.csdn.net/jiyanfeng1/article/details/8146139

    有些用户会使用直接断掉电源的方式来关闭linux,这是十分危险的。因为linux与windows不同,其后台运行着许多进程,所以强制关机可能会导 致进程的数据丢失�o使系统处于不稳定的状态�o甚至在有的系统中会损坏硬件设备。而在系统关机前使用shutdown命令�o系统管理员会通知所有登录的用户 系统将要关闭。并且login指令会被冻结�o即新的用户不能再登录。直接关机或者延迟一定的时间才关机都是可能的�o还可能重启。这是由所有进程 〔process〕都会收到系统所送达的信号〔signal〕决定的。这让像vi之类的程序有时间储存目前正在编辑的文档�o而像处理邮件〔mail〕和新 闻〔news〕的程序则可以正常地离开等等。
     shutdown执行它的工作是送信号〔signal〕给init程序�o要求它改变runlevel。Runlevel 0被用来停机〔halt〕�orunlevel 6是用来重新激活〔reboot〕系统�o而runlevel 1则是被用来让系统进入管理工作可以进行的状态�r这是预设的�o假定没有-h也没有-r参数给shutdown。要想了解在停机〔halt〕或者重新开机 〔reboot〕过程中做了哪些动作�o你可以在这个文件/etc/inittab里看到这些runlevels相关的资料

你可能感兴趣的:(shutdown,halt,reboot,poweroff)