Myszek512
Posts: 1
Joined: Sat Sep 02, 2017 9:01 pm

Update cluster via script

Mon Oct 09, 2017 9:47 pm

1 Raspberry Pi is fun, so I thought 10 would be better. While there is a lot of info & videos on physically building a Raspberry Pi cluster, there is almost nothing about software, or RPi to RPi communication.
The situation: RPi-100 -- RPi-109 The problem: How can I run a script from RPi-100 that will execute repeating commands on RPi-101 -- RPi109
"sudo apt-get update'
'sudo apt-get upgrade'
'sudo apt-get install <xxxxx>'
[If it matters, they all have static IP addresses: 192.168.1.100--192.168.1.109]

Thanks, Rob


jahboater
Posts: 4840
Joined: Wed Feb 04, 2015 6:38 pm

Re: Update cluster via script

Tue Oct 10, 2017 8:02 pm

Myszek512 wrote:
Mon Oct 09, 2017 9:47 pm
The situation: RPi-100 -- RPi-109 The problem: How can I run a script from RPi-100 that will execute repeating commands on RPi-101 -- RPi109
"sudo apt-get update'
'sudo apt-get upgrade'
'sudo apt-get install <xxxxx>'
[If it matters, they all have static IP addresses: 192.168.1.100--192.168.1.109]

Thanks, Rob
Yes,

ssh [email protected] 'sudo apt-get update'

You can put as many of these commands as you like in a simple bash script.

Obviously in a script you don't want it asking you for a password all the time.
This is avoided permanently with:-

ssh-keygen -t rsa

ssh-copy-id [email protected]
ssh-copy-id [email protected]
ssh-copy-id [email protected]
etc

S0litaire
Posts: 216
Joined: Thu Dec 29, 2011 4:24 pm
Location: Ayrshire, Scotland
Contact: ICQ Skype Twitter

Re: Update cluster via script

Sat Oct 21, 2017 5:32 pm

If they are all named in a similar way you could use something like this:

Code: Select all

for I in 1..4 ; do echo -n "RPi-$I:";ssh [email protected]$I.local [[enter command here]];done
I use it with my ClusterHat, you can easily use it to run a bash script for each device in turn.
--
Laters

Bill "Solitaire" C

Anáil nathrach, ortha bhas betha, do cheol déanta

Return to “Other projects”