[linux]通过ssh远程设定各服务器时间,从而实现集群时间同步
#!/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
每分钟执行一次。
[linux]通过ssh远程设定各服务器时间,从而实现集群时间同步的更多相关文章
- Linux 下 SSH 远程超时解决方案
Linux 下 SSH 远程超时解决方案 今天突然看到一个问题说是如何解决SSH远程超时的问题. 找了一点资料.用于解决这个需求~ 第一种:OpenSSH 配置文件设置 位于112行的 "C ...
- (转)详解Linux中SSH远程访问控制
详解Linux中SSH远程访问控制 原文:http://blog.51cto.com/dengqi/1260038 SSH:是一种安全通道协议,主要用来实现字符界面的远程登录,远程复制等功能(使用TC ...
- mac 通过 终端 ssh 远程连接 centos 服务器
mac 通过 终端 ssh 远程连接 centos 服务器 在终端下输入 ssh -l root 204.74.*.* 就可以连接了,这是端口没变的情况,还是原来的22 ssh -p 448 ...
- Oracle归档日志所在目录时间不对&&Oracle集群日志时间显示错误
Oracle归档日志所在目录时间不对&&Oracle集群日志时间显示错误 前言 这个问题在18年的时候遇到了,基本不注意并且集群或者数据库运行正常是很难注意到的. 忘记当时怎么发现的了 ...
- 在linux环境下安装redis并且搭建自己的redis集群
此文档主要介绍在linux环境下安装redis并且搭建自己的redis集群 搭建环境: ubuntun 16.04 + redis-3.0.6 本文章分为三个部分:redis安装.搭建redis集群 ...
- Linux:ssh远程执行命令并自动退出
ssh命令格式: [root@localhost ~]# ssh --helpusage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c ...
- linux利用ssh远程执行多台机器执行同样的命令
这篇文章主要介绍了ssh远程执行命令方法和Shell脚本实例,本文讲解了ssh执行远程操作方法和远程执行命令shell脚本示例,需要的朋友可以参考下 ssh执行远程操作命令格式代码如下: ssh -t ...
- SSH远程登录CentOS服务器
1.把ssh默认远程连接端口修改为2200编辑防火墙配置:vi /etc/sysconfig/iptables防火墙增加新端口2222 -A INPUT -m state --state NEW -m ...
- Linux下 SSH远程管理服务
第1章 SSH基本概述 1.1 SSH服务协议说明 SSH 是 Secure Shell Protocol 的简写,由 IETF 网络工作小组(Network Working Group )制定 在进 ...
随机推荐
- Python:树的遍历
各种遍历顺序如下图所示: 树的最大深度 # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = ...
- Socket_SSH-1
服务器端: import socket,os server=socket.socket() server.bind(('localhost',9999)) server.listen() while ...
- BZOJ5323 & 洛谷4562:[JXOI2018]游戏——题解
https://www.luogu.org/problemnew/show/P4562 https://www.lydsy.com/JudgeOnline/problem.php?id=5323 (B ...
- UVA.674 Coin Change (DP 完全背包)
UVA.674 Coin Change (DP) 题意分析 有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 每种硬币的数量是无限的.典型完全背包. 状态 ...
- lightoj 1245
lightoj 1245 Harmonic Number (II) 题意:给定一个 n ,求 n/1 + n/2 + …… + n/n 的值(这里的 "/" 是计算机的整数除法,向 ...
- HDU 3586 树形dp
Information Disturbing Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/ ...
- Web前端工程师-优秀简历汇总
Web前端工程师-优秀简历汇总 1. http://www.linqing07.com/resume.html 2. http://www.flqin.com/#page2 3. ht ...
- iframe的使用及操作
一.iframe的使用方法: 在一个页面中加入iframe代码,例如: <div class="myiframe"> <iframe src="test ...
- UVA 11040 Add bricks in the wall
https://vjudge.net/problem/UVA-11040 找规律 #include<cstdio> using namespace std; ][]; int main() ...
- poj 2541 Binary Witch
Binary Witch http://poj.org/problem?id=2541 Time Limit: 1000MS Memory Limit: 65536K Descript ...