I developed a process named X0 that continually appends some lines to a CSV file to register some electrical data as voltage or power.
This process run a python program and is started using following command:
sudo systemctl start getdata.Hypontech.system
The python code used to open CSV file in appending mode is following
def OpenDataFile():
global f
dt = datetime.now()
global iFileDay
iFileDay = dt.day
sFileDate = dt.strftime("%Y-%m-%d")
sFile = "./data.H1/Measures." + sFileDate + ".csv"
print("FILE: " + sFile)
f = open(sFile, "a")
f.write(sFileDate + ";" + sHeader)
f.write("\r\n")
When I use cat or tail Linux command, I see only lines written before X0 process is started.
How can I display last CSV lines (or content) without stopping X0 process?
If it is impossible using Linux standard command, is there a tool that allows that?
flush()is good, this is the right thing to do. Nevertheless that answer does not answer any of your explicit questions. The answer to the title is "catortailyou used; the fact you did not see the expected lines means they were not (yet) in the file". After learning about buffering and how to improve your program, do you still want to see lines you were expecting to see without stopping the process? If not then the question shall be rebuild to "why don't I see lines I expect and what to do to be able to?". Also see: XY problem.tail -f(follow) will display new lines when the OS sees them; as others have said this is subject to buffering