3 Replies Latest reply on Nov 5, 2015 2:38 AM by MunKeong Lee

    Control M v8: File Watcher


      Hi all, I've researched for answer on this discussion forum and found similar question regarding File Watcher, but nothing that helps me.


      We have control M v8.  I have a jobset with 2 jobs (1 is a File Watcher job and the other is my Phone job that processes source files).  There must be 2 files present before my Phone job runs.  File names are like this, with the only difference being the date.





      When File Watcher sees neither file, it waits and keeps checking every 300 seconds (or whatever the interval is).

      When File Watcher sees 1 of the files, it waits and keeps checking 300 seconds (or whatever the interval is).

      When File Watcher see 2 files, the File Watcher job completes with 0 status code and then starts my Phone job (the File Watcher job is a predecessor to the Phone job).


      After my Phone job completes, only 1 file will be left:




      The next day i'll get a new phone file:





      Again, my Phone jobset runs and starts the File Watcher job which repeats as listed above.


      There must be two Phone files present before my Phone job completes and before the File Watcher job is satisfied.


      Is there a way to set this up using the File Watcher attributes form/screen in control m 8?  Or will I be forced to create a rule to look for multiple files?  If I must create a rules file, how should I reference the date part of the file name as a variable?

        • 1. Re: Control M v8: File Watcher
          MunKeong Lee

          Hi Andre:

          Assuming that the name of the first file is using yesterday's date and the name of the second file is using today's date, you can define the 2 jobs using the FileWatcher template as follows:


          1st job:

          Path: /tmp/PhoneFile_%%YESTERDAY..txt


          %%YESTERDAY=%%$CALCDATE %%$DATE -1

          %%DD=%%SUBSTR %%YESTERDAY 7 2

          %%MM="%%SUBSTR %%YESTERDAY 5 2

          %%YYYY=%%SUBSTR %%YESTERDAY 1 4



          2nd job:

          Path: /tmp/PhoneFile_%%TODAY..txt

          %%DD=%%SUBSTR %%$DATE 7 2

          %%MM=%%SUBSTR %%$DATE 5 2

          %%YYYY=%%SUBSTR %%$DATE 1 4



          Provide appropriate values to the other filewatcher's parameters.




          • 2. Re: Control M v8: File Watcher

            Sorry it took so long for me to reply.  To summarize, I was able to use your suggestions to setup variables for the date (current and previous day).  However, another issue I wasn't aware of is that we may get multiple files per day, although we're supposed to get only one.


            For example,

            PhoneFile_101320150100.txt (received at 1am ET)

            PhoneFile_101420150030.txt (received at 12:30am ET)

            PhoneFile_101420151157.txt (this file is really the file for the 10/15/15, but it came a few minutes before midnight on 10/14).


            ...and this will change and is very sporadic.  I didn't know this before.


            So since I can't code for every possible scenario without a lot of complexity, I want to see if I can use the Minimal file age and Maximal file age parameters on the File Watcher attributes form.  If File Watcher detects a file that is more than 24 hrs old, it ignores it and waits and continues detecting.  If File Watcher finds a file that is less than 24 hrs old, then the File Watch job completes and allows its successor job to run.  Does that make sense?


            From reading the documentation the Minimal and Maximal file age parameters, they don't seem to work quite that way.  Can anyone suggest what would work?

            • 3. Re: Control M v8: File Watcher
              MunKeong Lee

              Hi Andre

              I need to understand your requirements. Do you mean that the phone job can be triggered as long as a new file that is less than 24 hours old arrives? If multiple files arrives on a single day, will they be processed immediately as well? Previously, it was based on 2 files being detected.