I need to launch a command when two files from different sources are present. Every file could arrive in different time, but I want to trigger the command when both were received. I have tried to do it with incrond, watching both directories for IN_CLOSE_WRITE and IN_MOVED_TO
/dir/path1 IN_CLOSE_WRITE,IN_MOVED_TO command
/dir/path2 IN_CLOSE_WRITE,IN_MOVED_TO command
The question is: when the first watch is triggered, how to wait for the second?
For example:
Time: 12:05 UTC - File1 arrives to Path1 command is waiting for Path2 watch
Time: 12:09 UTC - File2 arrives to Path2 command is launched
The command is coded in Go, but I could not find anything that help me.
More specifically, the system works as follows: There are two remote servers recording data in pcap, in periods of 6 hours, same periods. They record the same information, but from different VLANs. When the recordings have finished, they are uploaded to two different directories of the main server. Both recordings need to be uploaded to be able to compare and mix them, discarding duplicate packets. Recordings are not always uploaded in the same order, nor do they arrive at the same time. It depends on the communications between the remote servers and the main server.
The file names are allways the same pattern: _yyyymmddTHHMMSS.pcap. From example, files started recording 2020-10-15 18:01:00:
File1: vlan1_20201015T180100.pcap
File2: vlan2_20201015T180100.pcap
I am looking for a solution related with incrond and bash or a solution within the command in Go. A solution or a clue, since I am currently at a standstill.