I have a simple bash script that I added to /etc/init.d/ folder that I want to run at every boot to read imu data. I’m having an issue where the script’s content goes blank sometimes when I reboot although the actual file is still there. I asked about this on linux stack exchange and they said it may be due to physically cutting the power source when I’m shutting down the reach.
Does anyone know why the content of the file is getting erased and if there is a better method to run a script on startup?
Yes I am using the sync command and it seems to be helping. The weird thing is that sometimes the issue comes up on the 5th or 6th restart when the script should have been written to the file /disk already a long time ago.