0

I am implementing a process that needs to be started when a file was copied (it uses linux). The file is uploaded by external system. I have noticed that file is visible after the copy operation started but the copying takes a few minutes.

How can I recognize taht the copy operation has been finished?

skolukmar
  • 185
  • 1
  • 9
  • 1
    Different OSs have different APIs for detecting when a file is opened and closed. On Linux you can use `inotifywait` for that, and a portable work-around would be to check the file size (for ex. when the file size didn't change after a few minutes then the upload **should** be completed) – Fravadona Nov 15 '22 at 11:36
  • If you have a hand on the process that uploads the files then you can make it create an `.complete` or whatever file for signalling that the upload completed correctly – Fravadona Nov 15 '22 at 11:42
  • systemd supports `.path` units that automatically start a service on recognizing a filesystem change of the type they're configured to watch. – Charles Duffy Nov 15 '22 at 13:30
  • Or you can use incron, or inotifywait + a shell script, or... etc, etc, etc; tool recommendation requests are off-topic here. – Charles Duffy Nov 15 '22 at 13:31
  • As a proposed duplicate: [Executing a bash script upon file creation](https://stackoverflow.com/questions/14692353/executing-a-bash-script-upon-file-creation) -- but _do_ seriously consider the [systemd path-unit](https://www.freedesktop.org/software/systemd/man/systemd.path.html) approach; that question is back from 2013, when systemd wasn't as established as it is today. – Charles Duffy Nov 15 '22 at 13:32

0 Answers0