I am running openHAB 2.5.2-1 (Release Build) on raspi 3 / openhabian / Raspbian GNU/Linux 10
Trying to execute some commands / a script on Linux shutdown I was not successful so far.
I use runlevel system:
script is in /etc/init.d/ (a bash-script without .sh like the other scripts there, file rights exactly as the other scripts there, executable of course, same user / group)
-rwxr-xr-x 1 root root 884 Mar 23 21:47 writeback-persist
Then I created symlinks in /etc/rc6.d and /etc/rc0.d
lrwxrwxrwx 1 root root 29 Mar 23 22:54 K00aapersist -> /etc/init.d/writeback-persist
The script just consists of some tests to check if it runs:
echo “Start writeback from init.d” >> /var/log/test.log
date >> /var/log/test.log
cat /var/log/openhab2/openhab.log >> /var/log/test.log
If I reboot using shutdown -r now
the logs afterwards are not written.
I even put the same few commands into an existing script in /etc/init.d but also then the test.log is not written.
Needless to say that the script runs perfect if executed manually … or if I put the same statements into /etc/rc.local (but then they get executed during startup, not shutdown which is the wrong timing…)
I would appreciate very much some ideas what could be the solution …