Run script during reboot/upgrade/shutdown

i need to distinguish between power failure and normal restart caused by an update or a manual/scripted reboot. I came up with the (not ideal) solution of running a procd init script that simply writes the boot-up/shutdown times in a file. During power-up start() is called and the boot-up time is written in the log. During reboot stop() is not executed (as it would be expected) and no shutdown time is written in the log. Does anybody have an idea why stop() is not executed during reboot (aka calling reboot from the shell)?
Any better solution than mine is also good :slight_smile:

reboot -> reboot.sh -- which touches /etc/clean-reboot
/etc/init.d/96-clear-reboot-flag which removes /etc/clean-reboot

Times are challenging as during early boot (before NTP sync), the time is that of the latest file in /etc/ (as I recall), often a while in the past.

time is not an issue - i have a RTC.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.