I run a number of headless Pis, sometimes I get something wrong and I can't log in via ssh, how can one then shut down safely?
I guess the risk of simply pulling the power isn't *that* bad but one would prefer not to.
Didn't find your answer? Ask the community — no account required.
T
Theo
Unless you're prepared to plug in a monitor, or enable and connect a serial console, then pulling the plug is the only way.
Theo
R
R.Wieser
Chris,
Maybe adding a "shutdown" button as per the below ?
formatting link
(DDG search term "RPi shutdown button") Regards, Rudy Wieser
T
The Natural Philosopher
Not quite Theo.
You *could* set up a hardware interrupt on a GPIO pin that invokes some kind of (more or less) orderly shutdown.
And attach a 'reset' button. Or a 'power off' button. Depending on what you did in the interrupt service routine
C
Chris Green
Yes, presumably that's what the BBB's 'power off' button does, it sometimes takes quite a few seconds after clicking the button before the BBB actually powers down. What's rather nice is that if you click the button again the BBB powers up.
C
Chris Green
OP here, thank you, that's really useful, and not only for the shutdown button. I'm using the RPi to read/control several I2C devices (taking over from a BBB) and that page has lots of useful I2C information as well.
R
R.Wieser
Chris,
You're welcome, even though the I2C extras where (ofcourse) a lucky shot. :-)
One question though : I don't think that your above BBB means "Better Business Bureau", but than what /does/ it mean ?
Regards, Rudy Wieser
C
Chris Green
It means Beaglebone Black, a single board computer quite similar in some ways to the Pi. It was introduced about the same time with the specific aim of having open source *hardware*. It las a lot more I/O than the Pi, two 46-way sockets.
However it hasn't got updated like the Pi and so is now somewhat behind as regards processor power etc.
5
56g.1173
You can SSH into them and then "(sudo) shutdown now". That works.
Alas Pi's really DON'T have a proper 'reset' pin. You can MAKE a shutdown-pin by polling one of the GPIO pins though - attach it to a physical push-button switch.
Pi's are microPROCESSORS rather than microCONTROLLERS. Most modern microC's have a "weak pull-up" you can set for a pin. Then just ground the pin to register your button-press. For a Pi, you may prefer to use a pull-up resistor from the 3.3v pin - 10,000 ohms is fine. THEN poll, looking for a sudden change to zero volts. You can write a simple Python daemon and @reboot it to life in root crontab. Check maybe every one or one/half sec so you don't burn too much CPU. You can also use interrupts, but that's unnecessarily complicated most times.
R
R.Wieser
Chris,
Ah yes, I've heard about that one. Never seen one though.
:-) Not everyone yearns for having the newest-and-fastest thingamagotchy.
Take me, I've got a swell time working with a RPi... One? (one of the earliest versions, without mounting holes) running a Lite version (CLI interface only) of BullsEye.
Regards, Rudy Wieser
C
Chris Green
I have quite a selection of Pis back to quite early versions and all of them are CLI only.
C
Chris Green
Didn't you see the bit that says "...I can't log in via ssh."? :-)
R
R.Wieser
Chris,
I did install the full, GUI based version of BullsEye, just to see if it would work. It did.
But the lack of any kind of speed made me quickly decide that maybe a CLI version would work better. :-)
To be honest, I was pleasantly surprised that that not-too-old BullsEye wanted to boot on that rather ancient RPi.
Regards, Rudy Wieser
T
The Natural Philosopher
I assume Beagle Bone Black or similar?
T
The Natural Philosopher
Edited to display idiocy more clearly
C
Chris Elvidge
I've got Bookworm running (no gui) on Hardware : BCM2835 Revision : 900032 Serial : 00000000c72dee2a Model : Raspberry Pi Model B Plus Rev 1.2
I got it for £10 (still in it's box) on ebay.
J
John Aldridge
What I do on my Pis is run an application which watches for the insertion of a USB stick labelled SHUTDOWNPI.
formatting link
M
Martin Gregorie
The standard Linux "su - shutdown" or "su - shutdown --poweroff" should do the trick, while "man 8 shutdown" or "su - shutdown --help" tells you all about it.
Hint: If you're not quite sure what a command is called, but you want to see its manpage, running the command "apropos whatIwant" will show you all the manual pages whose NAME sentence contains that character string or something similar.
5
56g.1173
I'd hoped he'd figured that out already ... he CAN, if he sets it up correctly. Most common err on a Pi is to forget to enable the service ... either using the config GUI or manually with systemctl. I change the default port and the too-liberal login stuff in sshd_config too, just to be safe.
However a "clean shutdown" BUTTON would be a really good thing - ergo the description of how to go for that. Ya can also write your OWN little daemon, send "STOP" on port whatever, separate from SSH.
5
56g.1173
SSH is almost bulletproof ... hoped he'd figured it out ......
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.