Showing posts with label Job management. Show all posts
Showing posts with label Job management. Show all posts

10/21/09 Know the impact of using the ENDJOBABN command

If you use the ENDJOBABN command to end an active job that just won’t go away after the ENDJOB is issued, you need to be aware of the longer term impact of using this command.

When you use ENDJOBABN, a marker is set in the system that causes the next IPL to be considered an "abnormal" IPL – that is – the system will behave as if it ended abnormally, instead of in a controlled fashion from a PWRDWNSYS. This means that the first IPL you do after an ENDJOBABN will take longer than a normal IPL.

This is important to remember, because if you only IPL monthly or even less frequently, you might be surprised by the impact of an ENDJOBABN issued weeks prior.


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. Vision Solutions develops and sells iSeries high availability and AIX replication and clustering solutions. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.


9/16/09 How to obtain further message logging for interactive or submitted jobs

To change the message logging level, and thus gather more logging information on any job, you need to access and change the job parameters per one of the following:

- To change your own interactive job, enter the CHGJOB command, then press F4.

- To change another interactive job: Locate the job using WRKACTJOB SBS(subsystem), use OPTION 2 next to the job, press F4.

- To change a submitted job: Put the JOBQ on HLD status temporarily (WRKJOBQ jobqname, OPTION 3 to HOLD), submit the job, use WRKJOBQ OPTION 5 to “Work With JOBQ,” and use OPTION 2, press F4.

*CAUTION* Holding the JOBQ will hold all jobs being submitted into that JOBQ for the duration that the JOBQ is actually on hold. Once the message level is changed, it is critical to release the JOBQ.)

Once the interactive or batch job is identified, and the OPTION 2 “Change,” menu has been entered, do the following:

1) Press F10 for further detail.

2) Modify the parameters as follows: Message Logging: Level 4, Severity 00, Text *SECLVL, Log CL Program Commands *YES, press enter.

3) Release the JOBQ. (WRKJOBQ jobqname, OPTION 6 “Release”

*Note* The message level will only remain for the job it was changed for, and would need to be repeated anytime it is needed unless further measures are taken to change the Job Description, in which doing so affects all jobs that utilize that Job Description.


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. Vision Solutions develops and sells iSeries high availability and AIX replication and clustering solutions. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

5/19/09 How to see scheduled jobs in order of submission

When doing various system maintenance and management functions it is sometimes necessary to hold jobs on the Job Scheduler. Instead of using the command WRKJOBSCDE, which presents jobs alphabetically by name, use the command WRKJOBSCDE SEQ(*DATETIME). This will present the list of jobs in the order they are to be submitted, allowing you to quickly find those scheduled jobs that will occur during the timeframe of your system maintenance and management tasks.

Disclaimer:Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. Vision Solutions develops and sells iSeries high availability and AIX replication and clustering solutions. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

12/10/08 How to create a self-submitting CL program

Have you ever written a program that you did not want someone to be able to run interactively? The following code example can be used to create a CL program that will get submitted to batch even if it is called from a command line.

Note: The following is limited to programs with no parameters, but with some modification specific to the program, it can be made to process a program that has parameters.


PGM
/*********************************************************************/
/* Declare the program's file being used */
/*********************************************************************/
DCLF FILE(QADSPOBJ)

/*********************************************************************/
/* Declare program variables */
/*********************************************************************/
DCL &DEVICE *CHAR LEN(10) /* The job name running this pgm */
DCL &USER *CHAR LEN(10) /* The user running this pgm */
DCL &NBR *CHAR LEN(6) /* This job number */
DCL &TYPE *CHAR LEN(1) /* This job type */
DCL &MSGKEY *CHAR LEN(4) /* Message key for sbmjob routine*/
DCL &SENDER *CHAR LEN(80) /* The sender of a message */
DCL &PROGRAM *CHAR LEN(10) /* Program that sent a message */
DCL &CMD *CHAR LEN(1024) /* Cmd for QCMDEXC */
DCL &CMDLEN *DEC LEN(15 5) /* Length of command */
/*********************************************************************/
/* Declare standard error handling variables */
/*********************************************************************/
DCL &ERRORSW *LGL /* Standard error */
DCL &MSGID *CHAR LEN(7) /* Standard error */
DCL &MSG *CHAR LEN(512) /* Standard error */
DCL &MSGDTA *CHAR LEN(512) /* Standard error */
DCL &MSGF *CHAR LEN(10) /* Standard error */
DCL &MSGFLIB *CHAR LEN(10) /* Standard error */
DCL &KEYVAR *CHAR LEN(4) /* Standard error */
DCL &KEYVAR2 *CHAR LEN(4) /* Standard error */
DCL &RTNTYPE *CHAR LEN(2) /* Standard error */

/*********************************************************************/
/* Monitor for the global error to handle errors that are not */
/* specifically checked */
/*********************************************************************/
MONMSG MSGID(CPF0000) EXEC(GOTO STDERR1) /* Std err */

RTVJOBA JOB(&DEVICE) USER(&USER) NBR(&NBR) TYPE(&TYPE)
CHGVAR &CMDLEN VALUE(1024.0)
CHGVAR &CMD VALUE(' ')

/*********************************************************************/
/* If this program is called interactively submit it to batch */
/*********************************************************************/
IF (&TYPE = '1') THEN(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) TOPGMQ(*SAME) +
KEYVAR(&MSGKEY)
RCVMSG MSGTYPE(*INFO) MSGKEY(&MSGKEY) WAIT(*MAX) +
SENDER(&SENDER)
CHGVAR VAR(&PROGRAM) VALUE(%SST(&SENDER 27 10))
SBMJOB CMD(CALL PGM(&PROGRAM)) +
JOB(&PROGRAM) LOG(4 00 *SECLVL)
RCVMSG MSGTYPE(*COMP) MSGDTA(&MSGDTA) MSGID(&MSGID) +
MSGF(&MSGF) MSGFLIB(&MSGFLIB)
SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) TOPGMQ(*PRV) MSGTYPE(*COMP)
RETURN
ENDDO

/*********************************************************************/
/* Insert program code here */
/*********************************************************************/



END:
RETURN

/*********************************************************************/
/* Process the standard error handling routines */
/*********************************************************************/
STDERR1:
IF &ERRORSW SNDPGMMSG MSGID(CPF9999) +
MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
CHGVAR &ERRORSW '1' /* Set to fail on error */
RCVMSG MSGTYPE(*EXCP) RMV(*NO) KEYVAR(&KEYVAR)
STDERR2: RCVMSG MSGTYPE(*PRV) MSGKEY(&KEYVAR) RMV(*NO) +
KEYVAR(&KEYVAR2) MSG(&MSG) +
MSGDTA(&MSGDTA) MSGID(&MSGID) +
RTNTYPE(&RTNTYPE) MSGF(&MSGF) +
SNDMSGFLIB(&MSGFLIB)
IF (&RTNTYPE *NE '02') GOTO STDERR3
IF (&MSGID *NE ' ') SNDPGMMSG +
MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) MSGTYPE(*DIAG)
IF (&MSGID *EQ ' ') SNDPGMMSG +
MSG(&MSG) MSGTYPE(*DIAG)
RMVMSG MSGKEY(&KEYVAR2)
STDERR3: RCVMSG MSGKEY(&KEYVAR) MSGDTA(&MSGDTA) +
MSGID(&MSGID) MSGF(&MSGF) +
SNDMSGFLIB(&MSGFLIB)
SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE)
ENDPGM

Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

12/3/08 How to see space location locks

Using option 12 of the DSPJOB command may not show an abnormal number of locks, (i.e. it might just show a few object-level locks being held by the job), but if you are having locking issues there may be many “space location” locks that you don’t see. A space location lock is a symbolic locking protocol.

Unfortunately, there is no way to see space location lock information from a 5250 green screen; however, there is a way to view this with iSeries Navigator. Using “My Connections” in Navigator:
1. Expand the system you are interested in
2. Go to: Work Management > Active Jobs
3. Right-click on the job in question
4. Go to: Details > Locked Objects
5. At the top of this screen, go to: View > Customize this View > Include
6. Select the box to include space location locks

This view will show all locks—object level locks and/or space location locks. To show details about an individual lock, simply right-click on the lock of interest and select Properties. That display will show you more detailed information (such as how many locks this job holds on that object). Additionally, the ‘Details’ tab shows the module, library, program and instruction that was executed to gain that lock.


To learn more about space location locks, go to: http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzahw/rzahwsllco.htm


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

11/12/08 WRKACTJOB - the F21 key

By default, the WRKACTJOB screen shows commands at the top of the screen, but when you press F21, these commands are hidden and you will see six additional jobs on the screen.

Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

11/5/08 WRKACTJOB - the JOB parameter

When using the WRKACTJOB command, the JOB parameter can be used to see all jobs (*ALL appears by default) a specific active job by name, or to select and view multiple jobs using a wildcard.

As an example of a wildcard, the following would show all jobs that start with "BATCH":

WRKACTJOB JOB(BATCH*)


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

10/29/08 WRKACTJOB - The SBS parameter

When using the WRKACTJOB command, the SBS parameter defaults to *ALL, but you can use this parameter to show one, several or many subsystems.

For instance, the following command will show jobs associated with three different subsystems:

WRKACTJOB SBS(QBATCH QBATCH1 QBATCH2)



Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

08/12/08 Creating a single startup program for multiple systems

This tip is particularly useful if you are using an iSeries high availability product for disaster recovery purposes. The idea is to create one startup program that will work on two or more systems -- one source code for multiple systems.

Use a data area to define the system's role in the iSeries replication environment. For example, the production system data area would have a setting of SRC and the backup system the setting of TGT. You may also want to define a value of SWT when the system is in the process of switching.

When a system is the production system, you want production subsystems/processes to start when the system is IPL'd. When a system is the backup system, you likely do not want these subsystems/processes to be started when the backup system is IPL'd. Of course, there will be some things you will want to start on all systems regardless of its role.

In the startup program, retrieve the pre-defined data area and then process accordingly.

Example source code for the startup program:


PGM

DCL VAR(&SYSROLE) TYPE(*CHAR) LEN(3)
RTVDTAARA DTAARA(YOURLIB/SYSROLE (1 3)) RTNVAR(&RTNVAL)
MONMSG MSGID(CPF1015) EXEC(CHGVAR VAR(&RTNVAL) +
VALUE('UNK'))

SELECT
WHEN COND(&SYSROLE = 'SRC') THEN(DO)

/* INSERT COMMANDS TO RUN WHEN SYSTEM IS THE SOURCE */

ENDDO

WHEN COND(&SYSROLE = 'TGT') THEN(DO)

/* INSERT COMMANDS TO RUN WHEN SYSTEM IS THE TARGET */

ENDDO

WHEN COND(&SYSROLE = 'SWT') THEN(DO)

/* INSERT COMMANDS TO RUN WHEN SYSTEM IS MID SWITCH */

ENDDO
ENDSELECT

/* INSERT COMMANDS TO RUN REGARDLESS OF SYSTEM ROLE */

ENDPGM



Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

7/28/08 Using the System Request menu.

The System Request menu is basically a shortcut screen that allows you to access some commonly used commands without leaving the your current screen.

Accessing the System Request menu can be done in a variety of ways depending on your environment and emulation program. Common ways are: pressing the SHIFT and SysRq keys together, or if using PC emulation, right clicking your mouse and selecting ‘SysRq’ from the pop-up window.

Transfer to secondary display session.
Choosing Option 1 will give you a second sign on for the same session, but there is a caveat: once you start another session the first one is paused and it will not resume until you go back to it. This is important to remember if you are running an interactive query, compile, etc.

Cancel a display session
To cancel out the display session that your are viewing, use Option 2.

Display user messages
User messages for your log-on profile can be seen by selecting Option 4. From there you can also manage the messages (i.e. remove all or selected messages).

View System Operator messages (QSYSOPR) To display the system operator messages use Option 6. It takes you right to the QSYSOPR messages screen. This is particularly useful if your display session is running a program and receives an error message that needs to be answered.

View current job information
See your current job information by selecting option 7. This is particularly useful if you need to see job names and job numbers. If you have second display session running, you can see that job information too.




Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

6/2/08 How to end a job that won't end by itself

Occasionally jobs can get hung up causing them to not end on their own. When this happens, as a last resort, you can use the ENDJOBABN command to force the job to end.


Editor's note: An expanded discussion on this topic can be found here: 10/21/09 Know the impact of using the ENDJOBABN command


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

4/13/07 How to ensure a job creates a job log when it ends

Ever have a job that ends abnormally but does not create a job log?

The command CHGJOB *SECLVL can be used to change an active job so that it creates a job log, which will allow you to see what has caused it to end.

From the WRKACTJOB screen, find the job and type a 2 (Change) next to the job, then press F10 (Additional parameters)

The following will appear under Message Logging:
Level . . . . . . . . . . . . > 4
Severity . . . . . . . . . . . > 00
Text . . . . . . . . . . . . . > *NOLIST

In the Text field, change *NOLIST to *SECLVL

You can also change parameters on this screen to log additional information about the CL being run.

In the Log CL Program Commands field change *NO to *Yes

So, the CHGJOB would look like this:

Message logging:
Level . . . . . . . . . . . . 4
Severity . . . . . . . . . . . 00
Text . . . . . . . . . . . . . *SECLVL
Log CL program commands . . . . *YES

This would then produce a joblog such as QEZJOBLOG

If you are running this from a command line - then do a CHGJOB LOG(4 00 *SECLVL) LOGCLPGM(*YES) before running your job. This should produce a job log when it ends abnormally (abend) or is shutdown abnormally.

If you cannot change the job once you logon - then look at what job description is being used and change that to the following:

CHGJOBD LOG(4 00 *SECLVL) LOGCLPGM(*YES)

You may need to change the signoff command to LOG(*LIST) to keep it from ditching the job log. SIGNOFF LOG(*LIST) if this is an interactive job you are wishing to log.


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation.

3/7/08 How to quickly find jobs using high CPU

When a system is performing poorly, in terms of response time, here’s something that can help find the culprit:

WRKACTJOB

From the display, move the cursor to the CPU column heading and use F16 to sort the jobs by that column. From there, it is easy to determine which jobs are consuming system resources (and how much) at that point in time.

Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation.