franki Posted July 12, 2017 Posted July 12, 2017 Hi I need to execute some command when system is going down for halt/poweroff. I need to know this inside my script /etc/init.d/myScript which is called when system is going down. I used to do it by checking $runlevel variable and if it is set to 0, then system was going down for halt, it was working for instance in Raspbian a few years ago. However, in my Linux cubieboard2 4.9.12-sunxi Armbian this variable is not set, and when I execute "runlevel" command inside "STOP" case in myScript it says it is in N 5 runlevel which is not true because I have executed poweroff All tips are welcome Best Regards Marek
tkaiser Posted July 12, 2017 Posted July 12, 2017 29 minutes ago, franki said: it was working for instance in Raspbian a few years ago. In the meantime just like Debian Jessie or Ubuntu Xenial (you didn't tell which distro you use) Raspbian also uses systemd so it's googling for systemd check halt or reboot --> 1st hit https://stackoverflow.com/questions/25166085/how-can-a-systemd-controlled-service-distinguish-between-shutdown-and-reboot
franki Posted July 13, 2017 Author Posted July 13, 2017 Thanks, it helped me a lot Best Regards Marek
Recommended Posts