Jump to content

how to check whether Armbian is going down for halt or reboot


franki

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines