Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


hjohnson
2020-01-30T20:04:31Z
I have a job that reads in a file, then loops through 3 tasks - set job variable, load the variable, write a file (log). After the loop, where it has loaded all of the lines from the file that was read, I have it set to email the log file. The issue is, that I want the log file to send ONLY if there is an output in the error output for the powershell (load) task. I set the email task to only attach the file if the content has the error output from the powershell task in it. Unfortunately, this is not working.

I have a screen shot of the tasks, and then one of how the attachment filtering is set up.

I need to have the log created every day, but I only want it to send if there is an error at some point in the load. That way we can check on that particular member and verify data. But if we were to have the log file send every day, people would more than likely become complicit and eventually not look at it. Especially if we had a long run of no errors. The email can still run, but just not include the attachment unless there is an error.

Is there a way I am missing to set this up?


attachmentSetUp.PNG webcallLogSend.PNG
Sponsor
Forum information
thomas
2020-01-30T21:38:22Z
I guess that checking for file content can be tricky. Maybe linebreaks in the file, or encoding or something makes the 'contains' expression risky to use. I don't know.
I tried another way. Basically i send the file test.xt if there is any errorOutput, and if there is no error, I send a bogus filename that does not exist. If it doesn't exist, no attachment is being sent. It looks like this:

Capture.PNG

If variable errorOutput is empty, send the file with name 'NoFile'. It doesn't exist, so nothing is sent.
If errorOutput <> empty, send the file test.txt, which would be the log file in your case. It seemed to work in my test.

You could also check the modified date of the logfile. If modified date is greater than the start time of the current job run, there are errors. (unless you write to log anyway...)

thomas
hjohnson
2020-01-30T21:49:22Z
Yes, I am writing to the log file for each load, no matter if it is a failure or not.

I will try your suggestion and see how that works.

Thaks!
Joey S
2020-01-31T19:52:27Z
You just need to set a condition to check as a prereq for the email task

On the left side of the email task there is a condition column. Double click on your task then go to Conditions and Add a new Condition Set. Inside the Set you make a new condition. It can look to many different things. I would not suggest having it read your log for something like "Failure" as any one failure logged will result in the condition being reached even though the failure is "old".

I would have it look to the current output for the last run of the PS task for a certain keyword if there is one you know will exist on a failure. I am sure you can recreate a failure with PS that is static and will not change over time.

Here is a sample of a job that runs for me every 10 min and is pretty bullet proof. It checks a list of ports on a server through a loop. The output on the port check is "Connected"or "Not Connected". So my condition is "Send email if not connected is the result"

Pretty straight forward once you know what to look for as a guaranteed failure


Annotation 2020-01-31 134457.jpg Annotation 2020-01-31 134436.jpg Annotation 2020-01-31 134333.jpg Annotation 2020-01-31 134411.jpg
Scroll to Top