阅读量:0
在 Debian 系统中,你可以使用 systemd 的定时器(timer)功能来设置定时同步。以下是具体步骤:
-
安装 NTP 服务(如果尚未安装):
sudo apt update sudo apt install ntp -
启用并启动 NTP 服务:
sudo systemctl enable ntp sudo systemctl start ntp -
创建 systemd 定时器单元文件: 你需要创建一个定时器单元文件和一个服务单元文件。
-
创建服务单元文件
/etc/systemd/system/ntp-sync.service:[Unit] Description=Run NTP sync [Service] Type=oneshot ExecStart=/usr/sbin/ntpdate pool.ntp.org -
创建定时器单元文件
/etc/systemd/system/ntp-sync.timer:[Unit] Description=Run NTP sync every hour [Timer] OnCalendar=*-*-* *:00:00 Persistent=true Unit=ntp-sync.service [Install] WantedBy=timers.target这个定时器配置为每小时运行一次
ntpdate命令。
-
-
重新加载 systemd 配置:
sudo systemctl daemon-reload -
启动并启用定时器:
sudo systemctl start ntp-sync.timer sudo systemctl enable ntp-sync.timer -
检查定时器状态:
sudo systemctl list-timers --all你应该能看到
ntp-sync.timer的状态信息。
通过以上步骤,你就成功设置了 Debian 系统的定时同步功能。你可以根据需要调整 OnCalendar 行中的时间表达式,以适应不同的同步频率。
以上就是关于“Debian 定时器如何设置定时同步”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm