So I have successfully developed a filewatcher script that's running fine. The script reads a file which contains list of input files (full path to the file), delimited with
| and other information. Something like this:
/path/to/file/1.txt|600|900|Team1email@example.com /path/to/file/2.txt|630|930|Team2firstname.lastname@example.org /path/to/file/3.txt|2300|2359|Team3email@example.com
etc. First one is the file, second and third are timings between which the file usually comes, fourth is the team responsible for the file and 5th is their email.
The script runs every ten minutes in the background 24/7 and compares the current timings with the second and third column, if the current time falls in between these timings, checks if the file is there or not. When the end time (column 3) is less than ten minutes and the file hasn't arrived, then an email is sent to the team that the file is missing.
To check if a file arrived after it's defined time, I've set another condition which checks the endtime - current time value. If it is negative, then it checks if the file came after and missed it's SLA or not. If the file arrives late, the script sends an email saying that the SLA was missed for that file. It calculates the "SLA" missed time using current time-end time (3rd column). Example if the first file comes at 930, then (930-900) is 30 minutes late. All these works fine.
I have just one problem. If you look at the last line in my example - the timings end at 2359 and I can't calculate if the file arrived after 2359 (as that's the highest time in a day and this minus any value won't produce a negative value). Obviously, I also cannot calculate the right SLA miss time if it comes later than that. Example if the file comes at 100 hrs, then the script thinks that the file came before the SLA time and doesn't send any alert (100-2359 is negative).
How can I overcome this?