Skip to main content
2 of 3
edited body
Amazon Dies In Darkness
  • 10.4k
  • 39
  • 105
  • 163

What Linux shell command can I use to display content of a file in which another process is writing?

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?

schlebe
  • 395
  • 2
  • 17