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.


MSchwartz
2020-09-15T19:31:07Z
Is there a way to send a notification if a job has not run in a certain period of time?

We have many jobs set up with file triggers, and we expect those jobs to run every day. If they do not run (e.g. the file didn't show up), we want to investigate to see if there's a problem.

Here's one way I know it can be done:

  1. Create a separate job triggered every day at 12am
  2. Add a Wait task to wait 9 hours (until 9am)
  3. Add an Email task to notify that the original job did not run
  4. In the original job, add a VisualCron task that stops this separate job from running

This way, the email task will only run when the original job does not run thus does not stop the separate job.

However, this would require us to create a separate Wait job for every processing job we have.

Is there a better, more efficient way for us to accomplish this?
Sponsor
Forum information
thomas
2020-09-15T20:03:09Z
You can use the api for this, but I assume you know that. Using VisualCron only, I would try this:

Create a job, add a task of type Internal/Job report. Choose the jobs you want to include in this check:

image.png

Write to ouput or file, whichever you prefer

image.png

It generates output like this ( I added job name and last execution as report content)

image.png

Use this output to send mail based on the timestamp. It will require som additional logic ofcourse, but It shouldn't be to hard
bweston
2020-09-18T14:50:24Z
The job report approach is probably better, but I think at one point I had one set up so that in addition to the file trigger it had a time trigger to run once a day; the first task was a no-op, and the flow for it was...I've forgotten exactly how I set it up. I think it was "if the current execution is from the file trigger, continue. If the current execution is from a time trigger and the last time the file trigger triggered was over 24 hours ago, send a notification. If the current execution is from a time trigger, stop the job regardless."
MSchwartz
2020-09-18T16:00:51Z
Originally Posted by: thomas 

Create a job, add a task of type Internal/Job report. Choose the jobs you want to include in this check:
...
Use this output to send mail based on the timestamp. It will require som additional logic ofcourse, but It shouldn't be to hard


Originally Posted by: bweston 

If the current execution is from a time trigger and the last time the file trigger triggered was over 24 hours ago, send a notification.


That's the problem I'm running into. I don't see any way to tell VisualCron to do something if x date is older than y date. You can use < or > operators to compare numbers, but not strings like dates.
bweston
2020-09-18T16:42:29Z
Originally Posted by: MSchwartz 

Originally Posted by: thomas 

Create a job, add a task of type Internal/Job report. Choose the jobs you want to include in this check:
...
Use this output to send mail based on the timestamp. It will require som additional logic ofcourse, but It shouldn't be to hard


Originally Posted by: bweston 

If the current execution is from a time trigger and the last time the file trigger triggered was over 24 hours ago, send a notification.


That's the problem I'm running into. I don't see any way to tell VisualCron to do something if x date is older than y date. You can use < or > operators to compare numbers, but not strings like dates.



I did it by using "if other value" in the flow and wrapping the relevant date variable in something I could use to force it to the format yyyyMMddHHmmss I think. You can tell it to compare those as Int64. It may be necessary to tell it to add 0 days to a specified date to control the format that way, if I remember right, which gets very verbose, but it works.
Joey S
2020-09-30T22:28:07Z
You could add a task to your current job, at the end. This task would write out a file, called anything you want. In this file you write out the time of the last time the file trigger fired. {TRIGGER(YourGUIDForTheFileTrigger|LastTrigger|LastRun)}

Now add a second trigger, the file trigger you already had and one for a timed event.

Let's pretend you expect a daily file and the file usually comes in at 4 am, set your time trigger to run at 12 noon.

Task #1 would be to find your special file and read it
Task #2 would be your email indicating the file has not come in for X hours
In this task you can evaluate the date/time to current date/time (subtraction) and, if that number is greater than your threshold then you will send the email. If the number is less than the threshold then you skip this step by using a Condition. The condition is where the math is done and result evaluated. See here: https://www.visualcron.com/doc/H...dition_-_conditions.html 

The rest of the job would be what you normally have the job do.

In this way you can have your one job to maintain, each file trigger can be evaluated and each email can be setup to be sent to different people.

The only break down we see with this method is that holidays, long weekend, etc make the math hard and, basically, we send more emails than we would like but people know an email might be coming over a holiday because they do not expect a file to come in. Better to get an email when you expect it than to have a job get skipped when you don't
James Hagist
2020-10-15T20:34:02Z
@  Joey S

I was working on something very similiar to what you proposed above but when I use this comparison

{DATE(DaysBetween|{DATEFORMAT(M/d/yyyy)}|{TASK(b841f4f9-33aa-4237-92fc-eb5678507c42|StdOut)})}


I was hoping to get a negative number left date was less than the right. Instead I am always getting a positive.

Is there a better way to do the comparision?
Joey S
2020-10-22T19:34:57Z
Maybe something like this

{MATH(Subtract|Integer|{DATEFORMAT(M/d/yyyy)}|{TASK(b841f4f9-33aa-4237-92fc-eb5678507c42|StdOut)}|#0.00)}
Scroll to Top