时间定时同步

时间定时同步

1.查看时区:timedatectl
2.将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间:timedatectl set-local-rtc 1

timedatectl set-timezone Asia/Shanghai 设置系统时区为上海
3.timedatectl set-ntp no
4.timedatectl set-time ‘2021-01-11 10:00:00‘
5.clock -w
timedatectl set-local-rtc 1

cd /etc/sysconfig/network-scripts
vi ifcfg-eth0


DNS2=172.20.7.9
echo "DNS2=172.20.7.9" >>/etc/sysconfig/network-scripts/ifcfg-eth0
cat /etc/sysconfig/network-scripts/ifcfg-eth0
systemctl restart network
ping ntp.zjhu.edu.cn

yum -y install crontabs
systemctl start crond.service
systemctl enable crond.service
systemctl status  crond.service

crontab -e
0 */2 * * * ntpdate ntp.zjhu.edu.cn
*/1 * * * * /sbin/ntpdate ntp.zjhu.edu.cn

/sbin/ntpdate ntp.zjhu.edu.cn


yum install -y ntpdate
systemctl start ntpdate.service
systemctl status ntpdate.service
systemctl enable ntpdate.service

find / -name CentOS-7.6-x86_64-DVD-1810.iso
mount -o loop  /u01/CentOS-7.6-x86_64-DVD-1810.iso   /mnt
mount -o loop  /u01/bak/CentOS-7.6-x86_64-DVD-1810.iso   /mnt

mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/

echo "[base]" >> /etc/yum.repos.d/123.repo
echo "name=123" >> /etc/yum.repos.d/123.repo
echo "baseurl=file:///mnt" >> /etc/yum.repos.d/123.repo
echo "gpgcheck=0" >> /etc/yum.repos.d/123.repo
echo "enable=1" >> /etc/yum.repos.d/123.repo

yum makecache

时间定时同步

上一篇:《大脑幸福密码》


下一篇:设计模式-策略模式