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.


Christian@otto
2013-05-07T08:09:23Z
Hi !

Any Idea how to create a job checking every 10 seconds how many Jobs are currently running? More than 3 Jobs --> abort Job 4, 5, 6...

best regards.😁

Sponsor
Forum information
Support
2013-05-09T17:47:03Z
Not really possible right now - moving to Feature requests.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
bweston
2013-05-15T19:05:55Z
Originally Posted by: Christian@otto 

Hi !

Any Idea how to create a job checking every 10 seconds how many Jobs are currently running? More than 3 Jobs --> abort Job 4, 5, 6...

best regards.😁



Checking how many jobs are running?

param($address="localhost")
add-type -Path "c:\Program Files (x86)\VisualCron\VisualCron.dll"
add-type -Path "c:\Program Files (x86)\VisualCron\VisualCronAPI.dll"

$c = new-object VisualCronAPI.Client
$conn = new-object VisualCronAPI.Connection
$conn.Address = $address
$conn.UserName = 'username'
$conn.Password = 'password'
$s = $c.Connect($conn,$true)

($s.Jobs.GetAll() | ?{ $_.Stats.Status -eq "Running" }).Count


Now, aborting other jobs based on that...I don't have a suggestion for that off the top of my head. Run that every ten seconds, store the output to a custom variable, have every job use a condition of that variable being below a certain threshold? ...hard to say what might work, as I'm not clear on the use case.
Christian@otto
2013-05-16T07:54:05Z
Error:

Exception in Task: Method not found:
"System.Object System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(System.String, System.Reflection.ConstructorInfo[], System.Object[])"
bweston
2013-05-22T18:29:43Z
Originally Posted by: Christian@otto 

Error:

Exception in Task: Method not found:
"System.Object System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(System.String, System.Reflection.ConstructorInfo[], System.Object[])"



Sorry, I didn't notice your reply until now.

...I'm not sure what to make of that error, unless it means I'm running versions of something that make this work and you are not. I use the Powershell technique I outlined to watch for jobs that have been running for over two hours on two servers, a Windows Server 2003 machine running Powershell 2 and a Windows Server 2008 machine with Powershell 3, both running VisualCron 6.2.2 (which uses VisualCron Protocol Version 6.1.7).
Christian@otto
2013-05-23T07:45:36Z
I replace name, password and path, right? 🙂
bweston
2013-05-30T17:23:04Z
Assuming that's not where your VisualCron API dlls are, yes...
Scroll to Top