Trying to create a udev event to safely shutdown Pi

The Raspberry Pi is a series of credit card-sized single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and developing countries.

Post Reply
User avatar
/RaspberryPi
Corporate
Posts: 2449
Joined: Wed Jun 05, 2019 1:29 am

Trying to create a udev event to safely shutdown Pi

Post by /RaspberryPi »

I'm trying to create a udev event to safley shutdown my pi by removing a usb device, inspired by this post.

In /etc/udev/rules.d/ I created a file named 10-my.rules and added the code:
ACTION=="remove" , ATTRS{idProduct}=="235c" , ATTRS{idVendor}=="174c" , RUN+="sudo shutdown -h now" ​
I got the relevant product id and vendor id from using lsusb
When I test the code with:
udevadm test --action="remove" /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4 ​
near the end of a long list of rule files it's pseudo running is:
run: 'sudo shutdown -h now' ​
So it seems to be working, but when I reboot my pi and actually remove the usb drive nothing happens. Does my code look ok? Did I miss something? I'm not very familiar with linux and spent several hours worth of reading udev tutorials and watching youtube videos to get to this point, so any help is appreciated!

submitted by /u/hicsuntdracones-
[link] [comments]

More...
Post Reply

Return to “Raspberry Pi Forum”