#!/usr/bin/env bash

#all hosts should to  sync time, all hosts should no password login echo other

synchosts_array=("xufeng-1" "xufeng-2")

#currnt time in this host

currentDay=`date "+%Y-%m-%d"`

currentTime=`date "+%H:%M:%S"`

echo "current day in this host is "

echo $currentDay

echo "current time in this host is "

echo $currentTime

#loop host to set time

for hostname in ${synchosts_array[*]}

do

    echo $hostname

    ssh -t $hostname bash -c "'date -s '$currentDay' &&hwclock --systohc'"

    ssh -t $hostname bash -c "'date -s '$currentTime' &&hwclock --systohc'"

done

在某个节点上配置任务调度周期即可:

crontab -u root -e

*/ * * * * /opt/software/rootbin/synctime.sh >> /opt/software/rootbin/synctime.log

每分钟执行一次。

最新文章

  1. Two-Phase Commit (两阶段提交)
  2. 根据图片Uri获得图片文件
  3. Android框架 加载图片 库 Picasso 的使用简介
  4. C#中泛型和单链表
  5. 负载均衡server load balancer
  6. Linux驱动设备中的并发控制
  7. 剪花布条(kmp)
  8. JSP页面中<%!%>与<%%>与<%=%>
  9. 201521123026《JAVA程序设计》第13周学习总结
  10. Python的Django框架完成一个完整的论坛(源码以及思路)
  11. c++ 库函数cmath
  12. 压力(性能)测试及jmeter的使用
  13. linux 修改配色
  14. event对象的clientX,offsetX,screenX,pageX
  15. sql注入case
  16. IntelliJ IDEA src下新建包, 没有层级结构
  17. VS2015安装及单元测试
  18. Ajax异步验证登陆或者注册
  19. 【Python】unittest-3
  20. MySQL Transaction--MySQL与SQL Server在可重复读事务隔离级别上的差异

热门文章

  1. [CH弱省胡策R2]TATT
  2. POJ3384:Feng Shui——题解
  3. 洛谷4245:【模板】任意模数NTT——题解
  4. C++中swap函数
  5. ACM数学
  6. 常见的shell命令总结
  7. Java的各种中文乱码解决方法
  8. Consul 入门(二)
  9. Codeforces Round #344 (Div. 2) A
  10. ACM1753大明A+B