SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Reading Windows Scheduler status

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Reading Windows Scheduler status
Author Message
MichaelV



Joined: 21 Nov 2007
Posts: 15
Country: Singapore

Post Reading Windows Scheduler status Reply with quote
Hi All,

Is that possible? If so how can it be done.

The issue is that there is already a bunch of schedules being run,
it would be neat to extract it to see the status so that 24x7 can
be use with minimal changes on the system.

Regards,

Michael
Tue Sep 09, 2008 11:19 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
What do you mean by "Reading Windows Scheduler status?"
"status" is a such a broad term.
Tue Sep 09, 2008 11:35 pm View user's profile Send private message
MichaelV



Joined: 21 Nov 2007
Posts: 15
Country: Singapore

Post Windows Scheduler status Reply with quote
When you bring up Window Scheduler there is a column called Status.

I need to read that, to know of existing tasks got run or not.
Tue Sep 09, 2008 11:49 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
It is sure possible, but what does it have to do with 24x7 Scheduler and where in 24x7 you want to get/use this value?

I suggest you describe the context in which you need this status value, type of job for which you want to get the status and maybe provide a specific example, and indicate logical "connection" to 24x7 Scheduler. Without this information it is really hard to assist you and provide the right answer.


By the way, you are not confusing the 24x7 Scheduler and Windows Scheduler. Are you?
Tue Sep 09, 2008 11:59 pm View user's profile Send private message
MichaelV



Joined: 21 Nov 2007
Posts: 15
Country: Singapore

Post Reply with quote
No I'm not confusing the two schedulers.

Okay I'm not sure I can get them to switch over completely to 24x7.
So some jobs are still existing in Windows scheduler.

Lets say Job A, in windows scheduler is suppose to run at 6am.
It returns a status in windows scheduler either 0x0 as Okay or some other error otherwise
seen in the "status" column in the windows scheduler.

Now 24x7 is suppose to monitor this (say at 6.30am) and other file status to trigger
other alerts. So the question is how to read the windows scheduler for status.

All this would be a lot easier if I can shift the jobs in question to 24x7 which would
be ALOT easier to get status and to trigger scripts. May eventually allow that but
based on the current status.. we'll see.

Second problem is that how to insert jobs into a AS400 scheduler?
Any ideas?
Wed Sep 10, 2008 12:07 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
Ok, it makes sense now and your requirements are understandable.


You can use VBScript job in 24x7 to programmatically get status of a given job in Windows scheduler. If the status code is ok, create a dummy file whose only purpose is to server a as semaphore for other jobs in 24x7. These other jobs can be linked to the file existence or be made to check for file after they start.

Below is an example VBScript job that can show the status in a message box. In order to try it, replace WHATEVER with the actual job name. Modify this job as needed.


Code:
Sub Main
   Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
   Set colScheduledJobs = objWMIService.ExecQuery _
      ("select * from Win32_ScheduledJob where name='WHATEVER'")
   For Each objJob in colScheduledJobs
      MsgBox "Job ID: " & objJob.JobID & VbCrLf &_
            "Job Status: " & objJob.JobStatus & VbCrLf &_
            "Name: " & objJob.Name & VbCrLf &_
            "Status: " & objJob.Status
   Next
End Sub



Additionally: FileSystemObject in VBScript can be used to manipulate files, for example,

Code:
Set objFso = CreateObject("Scripting.FileSystemObject")
Set strFile = objFso.CreateTextFile("c:\myfile", False)
strFile.WriteLine ("Status: " & objJob.Status)
strFile.Close

Wed Sep 10, 2008 12:30 am View user's profile Send private message
MichaelV



Joined: 21 Nov 2007
Posts: 15
Country: Singapore

Post Reply with quote
Thanks for your help. Apparently there's two problems.
First that script you've provided works only if its created by the at command.
It does not work if it was created by the Task Scheduler.

Since MS in its infinite wisdom, did not provide any programming interface to the
Task Scheduler. The only way to get anything from it is

schtasks

which returns

TaskName Next Run Time Status
==================================== ======================== ===============
Allway Sync_{41DF5FABFF5C270A1FB263B 17:00:00, 9/10/2008 Could not start
ExBoot Schedule - TT 09:00:00, 9/11/2008 Could not start

which could in theory be parsed in some fashion.

Thanks for your help.
Wed Sep 10, 2008 1:28 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
The output seems like a fixed length text, so that parsing should be relatively easy. I suggest running schtasks with output redirection to a file cmd /C schtasks c:\whatever\myfile.txt, reading the output file line by line or entirely and splitting by lines, then chopping each line at fixed positions, trimming trailing spaces in each chunk, comparing first value (job name) to the job in question.

Surely a generic function could be made to allow getting status of an arbitrary job. This can be done relatively easy in both JAL and VBScript. Please let me know if you need further help with that.
Wed Sep 10, 2008 8:53 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.