It has already been asked here and I have found the solution for the first part of my question. So for the moment I have a bash script (script1) where I evaluate the sha1sum of a specific file (output.dat) periodically (lets say every 1 sec). When the
sha1sum_cur != sha1sum_prev then I run another script (script2) with some commands. Meaning this way that the file has modified.
My problem is that output.dat is quite a lot MBs and takes quite long to be written. So, I dont want to run script2 while data are being written to it, but after the process of writing data to it has finished. output.dat is being created by a fortran code, so lets say every 1h it deletes previous data and writes new ones but takes around 5min for that.
two last important notes:
1) Since I am submitting my jobs to a cluster, i dont have the permission to install inotify-tools.
2) I could call the script through the fortran code, once I
CALL system(./script2) but I would rather not do so, since its parallel and don't want to slow down its efficiency.
So the question is, what I could add to script1 so that it understands that the process of writing data to output.dat has finished?