Auto start script in /etc/init.d/ sometimes gets erased

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?


Could it be as simple as issuing the sync command to force writing to disk (flash memory)?

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.

Hmm that is odd. Once in a while you must be booting into another dimension. :alien:

1 Like

Overall, that should work. I have only two clues on what’s going on:

  • Is there a chance your script is trying to rewrite itself?
  • Maybe this is just due Reach being a systemd-dominated system and /etc/init.d being there for compatibility purposes. Try writing a service file.

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