Page 1 of 1

To shutdown all network computers

Posted: 2018/09/14 08:41:22
by nike
I have a centos 7 server ....Pls anyone can help me to make a shell script to shutdown all network computers (windows and linux) ..I will be grateful....

Re: To shutdown all network computers

Posted: 2018/09/14 13:00:58
by lightman47
It would need to login to each machine and, as root / sudo, perform shutdown -h now, then move on to the next machine as far as I know - that's for the Linux machines.

I doubt there's a way to do it from "outside" - otherwise anyone could do what you're trying to do, ant time they wished.

Re: To shutdown all network computers

Posted: 2018/09/14 21:16:05
by fdisk
Depending on your hardware there's a good chance to accomplish this task with WOL (wake on lan) instead of scripting around ssh.

However, personally I would prefer ansible as an orchestration tool - in my opinion this is a neat solution no matter how large your system pool is. And it comes with tons of other improvement...

Re: To shutdown all network computers

Posted: 2018/09/14 23:00:28
by MartinR
I've not used ansible myself (though having a look now), but the freeware xCAT gives you the psh (parallel shell) command. Once configured you can issue commands such as:

Code: Select all

# psh all shutdown -h now
or

Code: Select all

$ psh linux-servers sudo shutdown -h now
Assuming you can find a suitable Windows command, you could add that. psh uses ssh to connect and then just passes the rest of the line to whatever shell responds. The commands are issued in parallel, so sometimes the output can be a bit confusing.