This question is an exact duplicate of:
- Newly created file becomes 0 kb (data gets overwritten to nothing) on reboot in Linux
I've a shell script which create files programmatically by writing the contents of a variable to a file in the memory location.
file=/downloads/fileName.crt
variable="These contents are to be
written to the file"
echo "$variable" > "$file"
This works fine. I'm able to see that the file is written to and not NULL. But sometimes after running this script and after a reboot, the file contents become NULL. Why is this happening?
Link to full code:
Newly created file becomes NULL on reboot in Linux
This code is running on an industrial mobile Linux computer with very basic configuration.