drohl
Posts: 4
Joined: Sat Feb 21, 2015 5:16 pm

Startup/Shutdown control of multiple Pis

Thu Apr 02, 2015 8:10 pm

I've assembled a series of interactive pieces for a soon-to-open museum exhibit. Currently, I have 5 non-networked Pis, each set up to boot to the command line, automatically login as user pi and start a script (different script on all 5 Pis).

For the sanity of the exhibits department and longevity of input/output devices, I'm trying to come up with an easy way to turn all the Pis on and off. On is easy - when they receive power, the exhibit is fully operational within a minute or so. But I want a way to shut them all down. Would the best practice be
  • to wire a button to a GPIO pin on each, and set up a script to run a safe shutdown when pressed?
  • to network the Pis, and have one GUI/command prompt that would ssh to all the Pis and shut them all down?
  • to network the Pis so their clocks all sync, and have some way of doing a timed shutdown?
As I will not be the one looking after these Pis long-term, I'm looking for whatever route is most robust, clean, and easy-to-use.

User avatar
DougieLawson
Posts: 39301
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Startup/Shutdown control of multiple Pis

Thu Apr 02, 2015 11:02 pm

Code: Select all

#!/bin/bash

ssh root@pi2 halt
ssh root@pi3 halt
ssh root@pi4 halt
ssh root@pi5 halt
halt
You'll need to use ssh-keygen on each pi to enable ssh login without a password. Share the public keys round the others so that every RPi has a private key and the public key for all five pis in /root/.ssh/authorized_keys

The shutdown command allows you to set a time when it shuts the system down.

sudo crontab -e

Add

Code: Select all

@reboot shutdown -h 18:30 # down at 6:30pm
and that will be run at boot up.

There's also the at daemon sudo apt-get install at
echo "halt" | at 18:30
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “General discussion”