自动同步linux时间(修改时区)
自动同步linux时间
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | -- 1、下载ntpdate yum install -y ntpdate -- 2、调整时区为上海,也就是北京时间+8区 -- 注:想改其他时区也可以去看看/usr/share/zoneinfo目录 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime yes | cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime -- 3、使用NTP来同步时间 ntpdate us.pool.ntp.org -- 4、定时同步时间(每隔10分钟同步时钟) crontab -l > /tmp/crontab.bak echo "*/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP" >> /tmp/crontab.bak crontab /tmp/crontab.bak |
linux 7修改时区
1 2 3 4 5 6 | -- linux 7 timedatectl set-timezone "Asia/Shanghai" timedatectl set-time 2015-11-20 timedatectl set-time 15:58:30 timedatectl set-ntp true |