View previous topic :: View next topic
|
Author |
Message |
Philippe
New User
Joined: 10 Jan 2008 Posts: 17 Location: France
|
|
|
|
Hi all,
do you know how I can control the elapsed time for a stc ?
For example, I want to stop a particular stc (as I can do for a batch job with the time parameter) each time it runs more than 1 hour.
Thanks for your replies !
Philippe |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
The TIME parameter for a batch job does NOT impact elapsed time -- it controls CPU time. You could set a TIME parameter on the started task but again it will impact CPU time and not elapsed time. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
When you say "I want to stop...", do you mean a physical person (you or an operator) looking at the clock, or the program running in the STC checking for elapsed time ?
Is the program (running in the STC) available to check from time to time if a STOP command has been issued ?
This link could be useful: Communicating with a program. |
|
Back to top |
|
|
phunsoft
New User
Joined: 19 Jul 2018 Posts: 11 Location: Switzerland
|
|
|
|
Marso wrote: |
Is the program (running in the STC) available to check from time to time if a STOP command has been issued ? |
If the program can be changed, I'd suggest you add some code to attach a subtask. That subtask will do an STIMER WAIT,DINTVL==C'01000000'. When the hour is over, the code will continue to run and can communicate the main task to terminate now. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
You can use System Automation. |
|
Back to top |
|
|
Philippe
New User
Joined: 10 Jan 2008 Posts: 17 Location: France
|
|
|
|
Hi guys,
thanks for the replies.
I talked about the Time on the Jobparm which works with the elaps time. The System Automation option is intersting and I will work around that.
I'm talking about an automatic method to stop a stc without any human action.
Philippe |
|
Back to top |
|
|
phunsoft
New User
Joined: 19 Jul 2018 Posts: 11 Location: Switzerland
|
|
|
|
Philippe wrote: |
I talked about the Time on the Jobparm which works with the elaps time. |
The TIME parameter on the /*JOBPARM does indeed monitor elapsed time. JES2 will write WTOs when the job runs longer, that's it. It will not stop anything. So you would still need automation to catch the message and issue whatever command is needed to stop the STC.
Unfortunately, TIME on the /*JOBPARM is ignored for STCs. This is probably the reason you started this thread.
So, you seem to have automation, thus catching the message and do what is needed should not be a big deal. Maybe you can run the program as job instead of as STC?
There are only a few reasons why a program must run as STC. One would be it the program must run under the master subsystem (SUB=MSTR). |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 730 Location: Denmark
|
|
|
|
If you choose an external controller you must cancel the timer if the STC stops by itself before the time limit. Otherwise you might get a premature cancel for the next STC start.
I thought about various options, like using the JES2 automatic commands, but that doesn't handle crossing midnight very well as far as I can tell.
@Peter, re "add some code to attach a subtask. That subtask will do an STIMER WAIT,DINTVL==C'01000000" etc. Wouldn't it be more generally usable if you have a main task attaching the STC program and having the main task waiting for either a time-out, or termination of the STC task? |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1744 Location: Tirupur, India
|
|
|
|
Here is one way to do it through JES2 automatic commands. It can go upto 7 days delay, not more than that. - This is JES2 automatic commands limitation.
1. Get the started task details
2. Generate JES2 automatic commands
3. Issue and check for access errors if any on system log.
Include this step as the first step of the started task
Code: |
//CANCELR EXEC PGM=IKJEFT01,PARM='%CANSTC 5' <-- this task would be stopped after 5 minutes.
//SYSPROC DD DSN=WELLS.REXX.PDS,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
/*
|
The member WELLS.GREEN.PDS(CANSTC) has,
Code: |
/*REXX*/
/* SECTION 1: GET THE STARTED TASK DETAILS */
ASCB = C2D(STORAGE(224,4))
ASSB = C2D(STORAGE(D2X(ASCB+336),4))
JSAB = C2D(STORAGE(D2X(ASSB+168),4))
JBNM = STORAGE(D2X(JSAB+28),8)
JBID = STORAGE(D2X(JSAB+20),8)
JESN = SUBSTR(JBID,4,5)
/* SECTION 2: CALCULATE THE TIME FOR CANCELLING THE TASK */
PARSE ARG CANTIME
DATE_TODAY = DATE('D')
MINS_TODAY = DATE_TODAY * 1440 /* CONVERT TO MINUTES 24 * 60 = 1440 */
MINS_CANCEL = MINS_TODAY + TIME('M') + CANTIME /* TIME OF CANCELLING */
DIFF = MINS_CANCEL - MINS_TODAY
HOURDIFF = (MINS_CANCEL - MINS_TODAY) % 60
MINSDIFF = (MINS_CANCEL - MINS_TODAY) // 60
HOURDIFF = RIGHT(HOURDIFF,3,'0')
MINSDIFF = RIGHT(MINSDIFF,2,'0')
SAY 'YOU MENTIONED A DELAY OF ' CANTIME 'MINS'
SAY 'TASK' JBNM JESN ' WILL BE CANCELLED AT' HOURDIFF ||':'||MINSDIFF
CMD="/$TA,T="||HOURDIFF||"."||MINSDIFF||",''$C S("||JESN||"),JOBMASK=",
||STRIP(JBNM)||"''"
SAY 'JES COMMAND GENERATED=' CMD
/* SECTION 3: ISSUE THE JES COMMAND */
ISFRC = ISFCALLS("ON")
IF ISFRC ¬= 0 THEN DO
SAY "ISFCALLS RC" ISFRC
EXIT
END
ADDRESS SDSF "ISFEXEC '"CMD"'"
IF RC ¬= 0 THEN DO
SAY "ISFEXEC RC" RC
SAY ISFMSG
DO IM = 1 TO ISFMSG2.0
SAY ISFMSG2.IM
END
EXIT
END
IF RC = 0 THEN SAY 'COMMAND ISSUED SUCCESSFULLY' CMD
ELSE SAY 'ERROR: CHECK COMMAND ISSUING SECTION' RC
CALL ISFCALLS "OFF"
EXIT |
Output:
Code: |
IKJ56644I NO VALID TSO USERID, DEFAULT USER ATTRIBUTES USED
YOU MENTIONED A DELAY OF 5 MINS
TASK IHSAE001 00167 WILL BE CANCELLED AT 017:05
JES COMMAND GENERATED= /$TA,T=017.05,''$C S(00167),JOBMASK=IHSAE001''
COMMAND ISSUED SUCCESSFULLY /$TA,T=017.05,''$C S(00167),JOBMASK=IHSAE001''
READY
END |
Caveats:
The time parameter for the //CANCELR step can be only in minutes
The number of minutes cannot exceed more than 7 days - JES2 automatic commands limitation.
The job cannot go across year-end to next year. This can be modified by handling julian dates (feeling lazy to handle that now).
The USERID under which the started task runs must have authority to issue commands. OPERCMDS Authority.
If the started task spawns unix processes, check if those are also killed.
Friday & time for sarakku! cheers - omlette du fromage |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
Back to top |
|
|
phunsoft
New User
Joined: 19 Jul 2018 Posts: 11 Location: Switzerland
|
|
|
|
Willy Jensen wrote: |
Wouldn't it be more generally usable if you have a main task attaching the STC program and having the main task waiting for either a time-out, or termination of the STC task? |
@Willy: Yes, you can surely write this a general utility.
I was thinking there is a remote possibility the "stc" wants to run as the job step task. If not, your suggestion is preferrable. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
It is also possible to use TWS to stop/start a stc by means of the TWS Automation interface.
So that means a TWS application stops the stc, executes all housekeeping processes and starts the stc. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1744 Location: Tirupur, India
|
|
|
|
If you have BMC products, then it can be done through combination of Mainview Alarm Manager & Mainview AutoOper.
From Mainview screen JUSEZ, setup an alarm based on jobname and Elapsed variables.
This alarm would write a custom message to SYSLOG.
Then AutoOper would pick up the message and issue the cancel command.
There is a video tutorial of setting up alarms on BMC site. Let me know if you would need it. |
|
Back to top |
|
|
|