There is a very small, but finite risk of the Pi being turned off in the middle of a file writeHa ha, I have long experience contemplating this annoying and tricky problem! The straightforward solution I concocted back in 2003 (and am still happy with) is to simply write a new file on the same file system ... and then use (atomic) rename to clobber the original file - but only after the new file has been successfully written. This is described in detail at:
In reply to Re^2: Yet another config file editing programme : Tell me how to make it better !
by eyepopslikeamosquito
in thread Yet another config file editing programme : Tell me how to make it better !
by dazz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |