mardi 5 mai 2015

Automating shutting down several Raspberry Pis with "screen" command and "halt" command

I have configured the serial-to-USB ports of 30+ Raspberry Pis and connect all the ports to a server. So I can use serial port to log in each PI from the server with following commands:

sudo screen /dev/ttyUSB0 115200
sudo screen /dev/ttyUSB1 115200
....
sudo screen /dev/ttyUSB32 115200

To shut down one PI manually, I can log in the PI with one of the above commands. The terminal will first show blank screen, and display the login prompt after I pressing enter. I can then log in as root and use "halt" command.

My question is how I can automate this manual process for 30+ PIs with the script.

PS: I don't have ssh access to all the PIs, otherwise I can use ssh-keygen on each PI to enable SSH root login without a password. And then use a script similar to the following to login in each pi remotely and halt

ssh root@pi0 halt
ssh root@pi2 halt
ssh root@pi3 halt
....
ssh root@pi32 halt

Any ideas and suggestions would be appreciated! Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire