服务器系统时间不准确怎么办?

服务器系统时间不准确可能会导致日志错乱、任务调度失败、SSL证书校验错误等问题。以下是解决办法:


🌐 一、同步系统时间的方法

1. 使用 timedatectl 命令(适用于 systemd 系统)

timedatectl set-ntp true # 开启自动同步 timedatectl status # 查看当前时间状态

若未启用 NTP,可先安装 chrony 或 ntp 服务。


2. 安装并使用 chrony(推荐)

# 安装 sudo apt install chrony # Debian / Ubuntu sudo yum install chrony # CentOS / Rocky # 启动并设置开机自启 sudo systemctl enable --now chronyd # 查看同步状态 chronyc tracking


3. 手动设置时间(不推荐,容易飘移)

date -s "2025-07-21 15:00:00" # 手动设置时间


🧭 二、设置时区

确保系统时区正确,避免因为时区差异导致"时间看似不准":

timedatectl list-timezones # 查看可选时区 timedatectl set-timezone Asia/Shanghai


🛠️ 三、硬件时间与系统时间同步(可选)

hwclock -w # 将系统时间写入硬件时钟 hwclock -s # 将硬件时间写入系统时间

相关推荐
烟雨书信19 小时前
安全运维和系统安全
运维·安全
爱的si念19 小时前
嵌入式ARM64 基于RK3588原生SDK添加用户配置选项./build lunch & debian
linux·debian·嵌入式
穷人小水滴19 小时前
在 VirtualBox 虚拟机中安装 Fedora CoreOS 操作系统
linux·virtualbox·fedora
ʚʕ̯•͡˔•̯᷅ʔɞ LeeKuma19 小时前
nginx常用命令(备忘)
服务器·nginx
随意02319 小时前
文件I/O与I/O多路复用
linux
tianyuanwo20 小时前
Docker Registry 实现原理、适用场景、常用操作及搭建详解
运维·docker·容器·registry
大聪明-PLUS20 小时前
像 Docker 一样创建虚拟网络
linux·嵌入式·arm·smarc
FrozenLove_G21 小时前
机械硬盘的工作原理
服务器·常识
nightunderblackcat21 小时前
新手向:Python制作贪吃蛇游戏(Pygame)
python·游戏·pygame
Amy_au21 小时前
Dotnet 项目手动部署到AWS 和Github action CICD 流程总结
云计算·aws