• 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

  • 相关阅读:
    乐歌入选毕马威“第二届新国货50榜单”,用实力演绎国潮当自强
    专用神经网络处理器芯片,神经网络芯片的单片机
    秋招升级打怪拿 offer,10w+ 字总结的 Java 面试题
    el-cascader组件根据最后一级向上找到父级并设置默认值
    0085 查找算法
    Jdk8 动态编译 Java 源码为 Class 文件(三)
    Win11系统小组件打不开?Win11系统小组件无法打开解决方法
    9.Springboot整合Security很全
    生信教程:使用拓扑加权探索基因组进化(2)
    【JSON2WEB】06 JSON2WEB前端框架搭建
  • 原文地址:https://blog.csdn.net/FairyKunKun/article/details/126240277