You can do things like watch for the running program to exit, have it touch a file on exit, or wait for the output file to stop being written. Then stat the file. The script that watches can send you the mtime so you know exactly when the output file was last written. If you don't care when you get the notification, you can stat the file any time.