当前位置:首页>微思动态 > >详情
全国热线电话 400-881-4699

在线留言

【Linux专题】如何知道系统是否需要完全重启

发布作者:微思网络   发布时间:2022-09-02   浏览量:0

一个简单的场景: 执行完 yum update 命令后,是否需要重启服务器?



安装 yum-utils 工具
[root@localhost ~]# yum -y install yum-utils



检查是否需要重启
[root@localhost ~]# needs-restarting
[root@localhost ~]# echo $?
0



或使用 -r 选项
[root@localhost ~]# needs-restarting -r
No core libraries or services have been updated.
Reboot is probably not necessary.
[root@localhost ~]#


*注: 0 表示无需重启; 1 表示需要重启





现在,更新系统到最新,执行: yum -y update



更新完成后,再次查看是否需要重启系统



[root@localhost ~]# needs-restarting -r
Core libraries or services have been updated:
openssl-libs -> 1:1.0.2k-25.el7_9
linux-firmware -> 20200421-80.git78c0348.el7_9
Reboot is required to ensure that your system benefits from these updates. # 需要重启以确保你的系统从这些更新中受益
More information:
https://access.redhat.com/solutions/27943
[root@localhost ~]#



仅列出,需要重启的服务,可以尝试只重启服务,不重启系统


[root@localhost ~]# needs-restarting -s
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
rpcbind.service
NetworkManager.service
postfix.service
dbus.service
auditd.service
vmtoolsd.service
bluetooth.service
ksmtuned.service
vgauthd.service
libvirtd.service
systemd-udevd.service
smartd.service
firewalld.service
irqbalance.service
[root@localhost ~]#





返回顶部