I'm designing a piece of electronic hardware that may come into contact with water if there is a mechanical malfunction (e.g. a seal breaks). Inside the device, I have moisture sensors around all critical areas. I've already written a script that monitors these moisture sensors, but I want to write an emergency script that if any of the moisture sensors sense water, the system can be shut off quickly to avoid electrical damage to the device itself and anyone/anything nearby.
At the moment, all I was able to find was the following protocol:
import os
os.system('shutdown -P now')
Is there a trivial way of making the computer have a 'hard' shut down?
I've also considered having the main power be fed to the device through a relay that the computer can control so I can just physically cut power to the computer, but I was hoping there was a way to do this without having to use such a heavy duty power relay.
Using System Request (SysRq) and than calling
echo b > /proc/sysrq-trigger
to immediately reboot the system, without unmounting or syncing filesystems.Check this answer for more info:
https://unix.stackexchange.com/questions/163370/is-there-a-fastest-way-to-shutdown-the-system