打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[linux]通过ssh远程设定各服务器时间,从而实现集群时间同步
#!/usr/bin/env bash #all hosts should to sync time, all hosts should no password login echo othersynchosts_array=('xufeng-1' 'xufeng-2') #currnt time in this hostcurrentDay=`date '+%Y-%m-%d'`currentTime=`date '+%H:%M:%S'`echo 'current day in this host is 'echo $currentDayecho 'current time in this host is 'echo $currentTime #loop host to set timefor 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

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

每分钟执行一次。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
SSH免交互式分发秘钥
ShutIt:一个基于Python的shell自动化框架
Linux快速配置集群SSH互信
Perform silent/unattended iRedMail installation
通过SSH穿透jumpserver访问内部主机
时间比较
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服