How to poweroff multiple linux machines in a single command or script? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to poweroff multiple linux machines in a single command or script? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have more than 10 Linux machines. How may I power off all machines using a single script?

The password and user is the same for all of the machines.

Answer

There’s many mays to do it.

One option is to use ssh key pairs instead of passwords to ssh without prompting for password. Then, you can do this :

#!/bin/bash

for server; do ssh $server 'halt; exit'; done

Usage:

./script.bash server1 server2 1.2.3.4

Or you can use a better approach with a tool like or pssh

We are here to answer your question about How to poweroff multiple linux machines in a single command or script? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji