I ran into this issue just last week, it would have been nice to know this trick then! However, I realized something that made me rework things to handle VisualCron's method of triggering a file at a time. It's worth mentioning I think. I had a legacy process that operated on a folder, processing all files, that ran at a specified time. I moved it to VisualCron, with a file trigger and after copying multiple files to the folder the job started once for each file, and each instance tried to operate on all files. Once I cleaned up the mess and realized what happened (and not knowing Thomas' trick above) I reworked VisualCron and wrote a new script to handle accepting and operating on a file at a time.
Now depending on the settings, VisualCron will fire the file trigger after the file has been released (after the system is done writing the file). This is a good argument for reworking your process to handle a file at a time. You know the file is done being written to when VisualCron kicks it off (if that setting is checked). With the Stop Job method calling a program or operation that operates on all files, you better make sure all files are done being written to the folder before starting, and all files are present. If you had a large number of files being written to a folder, or a number of large files, the called program or copy operation could start when the first one arrives and finish before all files were done being written, or try to run on a partially written file (of course this depends on what that program or operation does, etc).
These factors may or may not apply to your situation, but it is something to consider carefully when setting up the job at any rate.
Consider changing your job to copy just the single file that caused the trigger. I do believe it is safer in the long run. By the way, the name of the file that caused the trigger to fire can be found in the variable: {TRIGGER(Active,LastTrigger,File.Result.Name)}. After processing, I move the file from our working folder which is set up in a job variable {JOB(Active,Variable,JobWorkingDir)} to a "processed" folder, also in a job variable. The trade off I suppose is higher overhead for processing each file one at a time but that is not a factor for us, where the increased reliability is (my opinion only, no facts to support this).
Hope this info helps and I will be interested to hear other folk's experiences.
Gary
Edited by user
2017-02-28T19:39:16Z
|
Reason: Not specified