On my machine, I have a file which is regenerated by an application every second – it contains different data each time, as it’s based on some realtime data.
I would like to have a copy of this file, which would contain what the original file contained 5 minutes ago. Is this somehow easily achievable? I would be happy to do this using some BASH scripting magic, but adding some wise, memory efficient code to that original application (written in c++) would also satisfy me 🙂
If disk space isn’t an issue, you could make the program create a new file every second instead of writing to the same file. You would need a total of 300 files (
5 min * 60 sec/min). The file name to write to would be$somename + timestamp() % 300. That way, to get the file 5 minutes ago, you would just access the file$somename + (timestamp()+1) % 300.