• 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

  • 相关阅读:
    面试 - react - Hooks
    CANopen之SDO,PDO
    《程序员做饭指南》霸榜 GitHub:不仅有量筒、烧杯,还用上了数学公式?
    【再识C进阶5(上)】详细介绍C语言文件操作——文件是用于存储数据
    自动化测试 | 多个自动化测试用例?多个自动化测试数据怎么管理?资深测试总结
    springboot---任务---整合quartz与task----定时任务(详细)
    java基于SpringBoot+vue的高校图书馆阅览室座位预约系统 elementui
    STM32(八)------- PWM输出
    openpnp - 74路西门子飞达控制板(主控板STM32_NUCLEO-144) - 验证
    【算法作业记录】
  • 原文地址:https://blog.csdn.net/FairyKunKun/article/details/126240277