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


barefootguru
2021-12-08T03:13:08Z
We have a lot of scheduled tasks which access a web server on another local machine. So if the web server is unavailable, many tasks error and have to be restarted.

I’m wanting to prevent this automatically: if the web server is unavailable, don’t try to run the tasks.
I’ve created a user variable EnableWebServerTasks=0/1
I’ve set up conditions on a few test tasks to only run if EnableWebServerTasks=1. Works great.

1. Does this sound like a sensible approach?
2. How can I automate setting the variable? I’m thinking use the ping task to ping the web server every minute, but I can’t work out how to set a variable based on the result
Sponsor
Forum information
thomas
2021-12-09T08:35:38Z
It is a possible solution I would say. Do note that if you add this condition to tasks (and not jobs), you may end up in a position where half your tasks have been executed, and then the job stop because the ping failed and the variable was set to zero. I would probably set it at the job level so that the job either runs or not, but it's your choice. I guess there are pros and cons for each

Anyway, to set the variable: The ping task is a bit funky. It returns success if ping succeds, and throws an exception if it fails. It would have been cleaner to just return true/false instead of throwing an exception imo. To get around it I would add a ping task and uncheck this:

image.png

It now returns success even if the ping fails, however the error output is still populated:

image.png

You can then set the variable based on the error output (it is empty if success):

{LOGIC(If|String|{TASK(PrevTask|StdErr)}|==||1|0)}

image.png
barefootguru
2021-12-09T21:24:31Z
That looks like exactly what I'm after, thank you!

I've changed the 2nd task to Set User Variable instead of Set Job Variable as it will be used by tasks in multiple jobs. I had to turn on Translate value to constant.

Good thought about job vs. task conditions, but in this case it's quite appropriate only some tasks in those jobs will run.
Joey S
2021-12-17T15:10:40Z
first off, I do not have a great solution off the top of my head but I know for sure a successful ping does not mean a machine is booted to windows or functioning. A another approach might be to query the machine for a service, like IIS (if that is what you are using). A service being up is more of an indicator of the machine being awake and functioning than a network ping. We have certainly had nonfunctioning web servers we could ping but not access and that were taking no data requests.
Support
2022-01-11T15:03:03Z
Originally Posted by: barefootguru 

We have a lot of scheduled tasks which access a web server on another local machine. So if the web server is unavailable, many tasks error and have to be restarted.

I’m wanting to prevent this automatically: if the web server is unavailable, don’t try to run the tasks.
I’ve created a user variable EnableWebServerTasks=0/1
I’ve set up conditions on a few test tasks to only run if EnableWebServerTasks=1. Works great.

1. Does this sound like a sensible approach?
2. How can I automate setting the variable? I’m thinking use the ping task to ping the web server every minute, but I can’t work out how to set a variable based on the result



You got some great suggestions from experienced forum members, did it solve your issue?
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
barefootguru
2022-01-11T20:58:28Z
Originally Posted by: Support 

You got some great suggestions from experienced forum members, did it solve your issue?



Yep, as noted above the approach detailed by thomas was perfect.
Scroll to Top