[root@tcloud ~]# timedatectl
Local time: Fri 2022-03-25 15:29:25 CST
Universal time: Fri 2022-03-25 07:29:25 UTC
RTC time: Fri 2022-03-25 07:29:24
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
开启NTP服务
[root@tcloud ~]# timedatectl set-ntp yes
[root@tcloud ~]# timedatectl
Local time: Fri 2022-03-25 15:52:30 CST
Universal time: Fri 2022-03-25 07:52:30 UTC
RTC time: Fri 2022-03-25 07:52:29
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
[root@tcloud ~]# ntpdate -d aliyun
28 Mar 15:33:22 ntpdate[17145]: ntpdate 4.2.6p5@1.2349-o Tue Jun 23 15:38:19 UTC 2020 (1)
Looking for host aliyun and service ntp
host found : aliyun
transmit(101.201.69.99)
101.201.69.99: Server dropped: no data
server 101.201.69.99, port 123
28 Mar 15:33:30 ntpdate[17145]: no server suitable for synchronization found
解决:关闭防火墙,配置`aliyun`服务器的安全组放开端口`123`。
复制代码
端口开放后
[root@tcloud ~]# ntpdate aliyun
28 Mar 16:06:57 ntpdate[2330]: adjust time server 101.201.69.99 offset 0.000112 sec
[/code] [size=5]添加定时任务[/size]
vim /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
[size=5]/etc/crontab 内容如下[/size]
[size=5]For details see man 4 crontabs[/size]
[size=5]Example of job definition:[/size]
[size=5].---------------- minute (0 - 59)[/size]
[size=5]| .------------- hour (0 - 23)[/size]
[size=5]| | .---------- day of month (1 - 31)[/size]