[英]How can i run two commands exactly at same time on two different unix servers?
My requirement is that i have to reboot two servers at same time (exactly same timestamp) . 我的要求是我必须同时(完全相同的时间戳)重新启动两台服务器。 So my plan is to create two shell script that will ssh to the server and trigger the reboot.
所以我的计划是创建两个shell脚本,这些脚本将SSH到服务器并触发重新启动。 My doubt is
我的疑问是
If you are doing it remotely, you could use a terminal emulator with broadcast input, so that what you type is sent to all sessions of the open terminal. 如果要远程执行操作,则可以使用带有广播输入的终端仿真器,以便将键入的内容发送到打开的终端的所有会话中。 On Linux tmux is one such emulator.
在Linux上, tmux是一种这样的模拟器。
The other easiest way is write a shell script which waits for the same timestamp on both machines and then both reboot. 另一种最简单的方法是编写一个shell脚本,该脚本在两台计算机上等待相同的时间戳,然后都重新启动。
Then, 然后,
If you need this just one time: on each servers do a 如果您仅需要一次:在每台服务器上执行一次
echo /path/to/your/script | at ....
( ....
being when you want it. See man at
). (
....
在您需要时。 man at
见man at
)。
If you need to do it several times: use crontab
instead of at
如果需要多次执行:使用
crontab
而不是at
(see man cron
and man crontab
) (请参阅
man cron
和man crontab
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.