Python has hooks in EXT3

We have several cron jobs that the ftp proxy registers on a centralized server. These files can be quite large and take some time to migrate. Part of the requirement of this project is to provide a registration mechanism in which we record the success or failure of these transmissions. It is quite simple.

My question is, is there a way to check if the file is currently being written? My first solution was to just double check the file size for a given period of time and check the file size. But an employee said that it might be possible to connect to the EXT3 file system via python and check the attributes to see if the file has been added to this file. My Google Fu appeared blank.

Is there a module for EXT3 or something else that would allow me to check the status of the file? The server runs Fedora Core 9 with the EXT3 file system.

+4
source share
2 answers

no special ext3 hooks needed; just check lsof , or rather, /proc/<pid>/fd/* and /proc/<pid>/fdinfo/* (where lsof gets the information, AFAICT). There you can check if the file is open, if it is writable, and the cursor position.

This is not the whole picture; but during the processing process, stdlib is no longer executed during the writing process, since most write operations are buffered and the kernel sees only large chunks of data, so any monitor with ext3 support will also not get this.

+7
source

There are no ext3 hooks to check what you want directly.

  • I suppose you could dig through the source code of the Fuser linux command, copy the part that finds the process owns the file and looks at this resource. When no one else opens the file, it is transferred.

Another approach:

  • Your cron jobs should report that they are finished.

We have our cron jobs that transfer files, just write an empty file name. After its transfer, the file name. Another approach is to pass them to a temporary file name, for example. filename.part, and then rename it to the file name. Renaming is atomic. In both cases, you check several times until you see the file name or filename.finished

+1
source

All Articles