Because of the project needs, in the CentOS6.3 system, using the shell script I wrote to update the software, the operator will habitually immediately restart the power. However, after rebooting, the software is not working properly. Party a variety and I want reason ah ... It really made me miserable.
All kinds of asked Niang have Ah, there is no solution.
I did a few scripts upgrade experiments in the virtual machine, and there was no problem. Later, I think they update the device immediately after the power-off restart, try to give the virtual machine also do a power test test. Sure enough, after troubleshooting the power-off restart part of the software size becomes 0byte. So the startup of the software starting from the root does not work.
Really because the software immediately after the failure to power off the cause.
The next step is to work out how to save the file in the case of a power outage immediately.
The following online search for information:
In the Linux/unix system, it is usually put into the memory buffer in the process of file or data processing, and then written to disk when appropriate, to improve the efficiency of the system operation.
Workaround: Use the Sync command to force the data on the buffer to be written to disk.
Write this command two times at the end of the software upgrade script to ensure that the upgrade script is written to the hard disk immediately after the software is copied. At this point, the problem is resolved completely.
In fact, this command has been seen in some scripts. At that time I was also curious to know what the order was for, but I did not delve into it. It's really a fall into your wit. Fortunately, party A has no idea how quickly I can solve this problem.
This article is from the "Star Wind Memories" blog, please be sure to keep this source http://yuyongid.blog.51cto.com/10626891/1685043
Problems with file loss after a sudden power outage in Linux