• Linux的关机和重启


    一、Linux作为服务器系统,在关机或重启前,应当做好充分的检查准备。

    查看当前系统中的登录用户,      当前网络连接信息,            当前系统的进程状态。

    1、首先调用who命令,查看当前登录用户。

    [root@centos6basicser ~]# who
    

    2、使用netstat命令,查看当前网络连接信息。

    [root@centos6basicser ~]# netstat -tpln


    3、使用ps命令,显示当前系统的进程状态。

    [root@centos6basicser ~]# ps -aux

    二、使用shutdown命令,通知当前所有登录用户,计划关机重启的时间、原因。

    1、shutdown -k,向所有登录用户发出警告信息(仅做提示信息),将在预定时间,或预定时间段内(30分钟)关机,但不会实际关机。

    [root@centos6basicser ~]# shutdown -k 22:11 'The System will shutdown at 22:11 tonight, Please save your data as soon as possible.'

    [root@centos6basicser ~]# shutdown -k +30 'The System will shutdown in 30 mins, Please save your data as soon as possible.'

    三、使用sync命令,用来强制将内存缓冲区中的数据立即写入磁盘中,更新超块信息,防止数据丢失。

    1、sync命令,建议多次执行,保证数据安全。

    1. [root@centos6basicser ~]# sync
    2. [root@centos6basicser ~]# sync
    3. [root@centos6basicser ~]# sync

     四、推荐使用shutdown命令,进行关机、重启操作。

    shutdown命令,是一种安全的方式关闭系统,所有登陆用户都可以看到关机信息提示,并且登录将被阻塞,也就是新的用户不能再登录。

    shutdown命令,可以直接关机,或是延时关机,同样可以进行重启系统。         

    不推荐使用其他关机或重启命令,比如:poweroff、reboot、halt、init。

    1、shutdown -h ,预定时间关机,或预定时间段内(30分钟)关机,并向所有登录用户发出警告信息。

    1. [root@centos6basicser ~]# shutdown -h 22:11 'The System will shutdown at 22:11 tonight, Please save your data as soon as possible.'
    2.  
    3. [root@centos6basicser ~]# shutdown -h +30 'The System will shutdown in 30 mins, Please save your data as soon as possible.'

    2、shutdown -h now,现在立即关机

    [root@centos6basicser ~]# shutdown -h now

    3、shutdown -r,预定时间重启,或预定时间段内(30分钟)重启,并向所有登录用户发出警告信息。

    1. [root@centos6basicser ~]# shutdown -r 22:11 'The System will reboot at 22:11 tonight, Please save your data as soon as possible.'
    2.  
    3. [root@centos6basicser ~]# shutdown -r +30 'The System will reboot in 30 mins, Please save your data as soon as possible.'

    4、shutdown -r now,现在立即重启

    [root@centos6basicser ~]# shutdown -r now

  • 相关阅读:
    Java中JVM指什么呢?她拥有哪些功能及特征呢?
    数据结构与算法 #18 下跳棋,极富想象力的同向双指针模拟
    (JAVA)[COCI2006-2007#2] ABC
    3D建模设计软件犀牛7--Rhinoceros 7 Mac
    猿创征文|微信小程序扫描二维码如何跳转小程序内指定页面并传递参数给目标页面?
    完成原型设计的五个步骤
    JUnit测试进阶(Private测试)
    Apache实现weblogic集群配置
    Maven 入门教程
    计算机毕业设计Java游泳馆管理平台(系统+程序+mysql数据库+Lw文档)
  • 原文地址:https://blog.csdn.net/FairyKunKun/article/details/126240277