33

Magic SysRq Key This should get you started. The magic SysRq key is a key combination understood by the Linux kernel, which allows the user to perform various low-level commands regardless of the system's state. It is often used to recover from freezes, or to reboot a computer without corrupting the filesystem. Its effect is similar to the ...


28

Although it should be regarded as a last resort since it does increase the risk of filesystem corruption, unplugging the cord is usually okay if the green ACT light is not flashing intensely. By default the ACT led shows I/O activity on the SD card. If it is off, most likely the system is idle. This is not necessarily true, but killing a system that is ...


26

I don't make a habit of unplugging the pi in the sense of eschewing shutting them down properly except when I've lost networking on a headless pi, in which case I am usually too lazy to plug in a keyboard, etc. Generally I always check to make sure the green ACT light is not on at that point; for recent models (or firmware?) this will be off when the SD card ...


8

The "documentation" for gpio-shutdown is Name: gpio-shutdown Info: Initiates a shutdown when GPIO pin changes. The given GPIO pin is configured as an input key that generates KEY_POWER events. This event is handled by systemd-logind by initiating a shutdown. Systemd versions older than 225 need an udev rule enable ...


6

sudo poweroff means shut down and stay off. The watchdog does not, and should not, intercept this. The behaviour you are experiencing is correct and you should not expect the watchdog to restart a powered-off system. I don't think this is what you are wanting to do though. If you want to restart the pi. you should use the command sudo reboot instead. And in ...


6

I/O failure is a common cause of this; processes suffering from such are stuck in an uninterruptible sleep. If this is widespread and includes critical processes, the entire system will stutter and stall -- although from a GUI perspective this may be exaggerated in that it is mostly the GUI that is stalling. Such processes can be identified with diagnostic ...


5

If you are using systemd, just put your script to /lib/systemd/system-shutdown/ as described here and here. EDIT: If it's not working try this one: Create a systemd service: /etc/systemd/system/yourSript.service with following lines: [Unit] Description=yourScript [Service] Type=oneshot RemainAfterExit=true ExecStart=/bin/true ExecStop=/usr/local/bin/...


4

I see two ways of doing this: 1. UUID Based You could write a very simple script, possibly in Python, to check for a specific UUID to be plugged into the Pi. The script would then shutdown the Pi. It would go something like this: import os import time while True: if "123456789-1234-1234-1234-1234567890" in os.popen("ls /dev/disk/by-uuid/").read(): ...


4

Shutting down the Pi properly can be done using either the GUI or the command-line. All the GUI does is invoke the proper command-line command. Different OS's and different users will have different setups as to whether the Pi boots to the GUI or to the command-line. Raspbian defaults to the GUI since it endeavors to be user-friendly for new users not ...


4

I didn't wade through all the rant you linked, but the author doesn't seem to understand the watchdog. There is a BCM hardware watchdog; If you want to start the hardware watchdog include dtparam=watchdog=on in /boot/config.txt In and of itself this does little, although it should restart the system if not "kicked" regularly. You can write code which opens ...


4

Go to this link and search for 'gpio-shutdown', it will give you steps to implement the gpio shutdown: https://www.stderr.nl/Blog/Hardware/RaspberryPi/PowerButton.html


4

EDIT 2: You can use a dhcpcd exit hook script. The script is called on each dhcpcd event and checks the reason for calling dhcpcd and the related interface. Create the script /etc/dhcpcd.exit-hook (usually it doesn't exists, otherwise edit it): if [ "$reason" = NOCARRIER ] && [ "$interface" = eth0 ] then echo "$(date) - eth0 DOWN, will shutdown ...


4

use post-up and post-down hook options in network script /etc/network/interfaces , you can create a simple script for shutdown, lets call it sd.sh executing which system will be shut down, so your network interfaces script will look like # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' # Include files from /etc/network/interfaces.d: source-...


4

You've made a couple of mistakes, all par for the course. Let's step through this, get it working, and hopefully learn one other trick to help you help yourself in the future: First, the "other trick": When you run a command from the terminal, your error messages stderr go to the terminal, and you see them immediately. When you run a command as a cron user,...


4

The Pi has 3 "components" the CPU, GPIO and Video Core which are relatively independent. Even when the Pi is shutdown the Video Core continues to run, and the GPIO pins retain their state; only the CPU is not running. (All Pi models before the Pi4 have identical GPIO and Video Core; only the CPU changed on the Pi2 and the Pi3. The Pi4 is all new.) ...


3

No need to guess; just plug in the keyboard and type this and hit enter: sudo shutdown -h now The shutdown command needs a root privilege to execute.


3

You can not rely on the 5V from the UBEC - because the UBEC is designed to maintain voltage even when input fails. It is not difficult to detect. Dry cells are effectively exhausted when the voltage falls to ~1.0V - here 8V. A voltage divider (connected across the battery) which will produce 1.3V when battery falls to 8V connected to a GPIO will go low. ...


3

MCP3008 can do that. You can build module for mesure voltage. Here is some links what can help you: https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/overview https://www.abelectronics.co.uk/p/56/ADC-Pi-Plus-Raspberry-Pi-Analogue-to-Digital-converter What I will do is made one converter what will mesure ...


3

Yes there is a way to disable GPIO3 (physical pin 5) pulled low to boot. In /boot/config.txt add the line dtoverlay=gpio-poweroff See the documentation for overlays in /boot/overlays/README. The entry for gpio-poweroff states: Name: gpio-poweroff Info: Drives a GPIO high or low on poweroff (including halt). Enabling this overlay will prevent ...


3

Something worth noting from the manual page for halt, poweroff and reboot is: These are legacy commands available for compatibility only. At the bottom is a "see also" for systemctl, and man systemctl has further details regarding the difference between the three things (in context, systemctl halt, systemctl reboot, etc). As Milliways points out in a ...


3

This howchoo post shows how to connect an LED to show the status of the Pi. The LED is steady on when the Pi is running, and off after shutdown. Briefly: Add this line to /boot/config.txt, and reboot enable_uart=1 Connect the TxD pin (GPIO pin 8) to the positive lead of a 2 or 3 volt LED. Connect a ground pin (e.g. GPIO pin 6) to a 330 ohm resistor, ...


3

The Pi has 3 "components" the CPU, GPIO and Video Core which are relatively independent. Even when the Pi is shutdown the Video Core continues to run, and the GPIO pins retain their state; only the CPU is not running. The 3.3V is supplied by separate circuitry and will be present while ever the Pi is connected to a 5V supply. The best way to reliably ...


3

The (native) ext4 filesystem is said to be robust with respect to power outages (ref.). I'd guess that file system corruption due to a shortcoming of ext4 is less likely than random corruption of your SD card. If that's true, consider spending a bit more for a high-quality SD card & don't worry too much about tweaking the filesystem. Maintaining a good ...


3

You need the supercaps to be in parallel to the power supply, not in series. However, before fixing your circuit, mind a few things: If you simply connect your supercaps between 0 and 5V, most power supplies / batteries will have trouble starting your system, since a discharged capacitor is essentially a short circuit. Most power supplies handle shorts ...


2

Courtesy of @goldilocks and @SlySven it has been confirmed that there is no way to disable the wake-from-halt feature (= Pulling GPIO5 low causes RPi to boot). The RRC2040 has a builtin feature which allows it to act as an I2C master in order to send updates to Smart Chargers and an SMBus Host. This subsequently also causes the RPi to boot if the I2C SCLK ...


2

You would have to experiment but I believe the simplest and least intrusive method would be to disable serial boot messages and monitor the UART TX line (GPIO 14, pin 8). This line will go high during boot and go low at power down.


2

Instead of a $50 Rubber Ducky you could get a $5 Arduino Beetle (a clone of Leonardo which fits directly into a USB socket): Look into Arduino Keyboard samples to see how it should be programmed. I have used one such board to send Ctrl+Alt+Del, password, Enter to log into a Windows PC. In your case, you'll be sending something like Ctrl+Alt+F1, sudo ...


2

Not sure if I've observed this just plain not work before, although calling shutdown in an ssh session may often cause it to hang on your side. I'll hazard a guess and say the reason you have this problem with wifi but not ethernet is because of the bit of latency involved. TBH that's a dubious, unsatisfying guess, but I don't think we need a complete ...


2

Do not pull the plug until the OS has shutdown completely. If you do, you risk corrupting the SD card and then needing to reformat and re-install. You can power down from the menu, once the green activity light goes off permanently and your display is off, you can safely assume the OS is done powering down and you can pull the plug. If you fancy the command-...


2

No; it is not possible without some additional hardware. Additional Information:- When the Pi is shutdown, it enters a HALT state. However there is still code running, which is why the Pin5 can reboot. See https://raspberrypi.stackexchange.com/a/19754/8697 for some explanation. If the Pi has never been booted Pin5 will do nothing. A better solution for ...


Only top voted, non community-wiki answers of a minimum length are eligible