Aaron,

Here tis.
_________________________________________________________

CMD PROMPT('Kill a job immediately')
PARM KWD(JOB) TYPE(*NAME) PROMPT('Job name')

_________________________________________________________

PGM (&JOBNAM)
DCL VAR(&JOBNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&USRNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBNBR) TYPE(*CHAR) LEN(6)
DCL VAR(&JOBVAR) TYPE(*CHAR) LEN(26)
DCL VAR(&JOBSTS) TYPE(*CHAR) LEN(10)
DCL VAR(&SPCNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&SPCLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&USRSPC) TYPE(*CHAR) LEN(20)
DCL VAR(&BIN4) TYPE(*CHAR) LEN(4)
DCL VAR(&SPCTXT) TYPE(*CHAR) LEN(50)
DCL VAR(&APIERR) TYPE(*CHAR) LEN(256) +
VALUE(X'0000000000000000')
DCL VAR(&LENDTA) TYPE(*CHAR) LEN(4)
DCL VAR(&STRPOS) TYPE(*CHAR) LEN(4)
DCL VAR(&KEYCNT) TYPE(*CHAR) LEN(4)
DCL VAR(&KEYFLD) TYPE(*CHAR) LEN(4)
DCL VAR(&LSTPOS) TYPE(*DEC) LEN(9)
DCL VAR(&LSTSIZ) TYPE(*DEC) LEN(9)
DCL VAR(&S) TYPE(*DEC) LEN(9)
DCL VAR(&COUNT) TYPE(*DEC) LEN(9)
DCL VAR(&LSTCNT) TYPE(*DEC) LEN(9)
DCL VAR(&RCVAPI) TYPE(*CHAR) LEN(140)
DCL VAR(&LIST) TYPE(*CHAR) LEN(256)
DCL VAR(&QJOBL) TYPE(*CHAR) LEN(26)
DCL VAR(&DEC9) TYPE(*DEC) LEN(9)
DCL VAR(&PID) TYPE(*CHAR) LEN(11)
DCL VAR(&NOT1ST) TYPE(*LGL)

MONMSG CPF0000 EXEC(GOTO ERROR)

CHGVAR %SST(&JOBVAR 01 10) &JOBNAM
CHGVAR %SST(&JOBVAR 11 10) '*ALL'
CHGVAR %SST(&JOBVAR 21 6) '*ALL'
CHGVAR &JOBSTS '*ACTIVE'

/* Create 2K user space using the create space API QUSCRTUS
*/
CHGVAR VAR(&SPCNAM) VALUE(QUSLJOB)
CHGVAR VAR(&SPCLIB) VALUE(QTEMP)
CHGVAR VAR(&USRSPC) VALUE(&SPCNAM *CAT &SPCLIB)
CHGVAR VAR(&SPCTXT) VALUE(&SPCNAM)

CHGVAR %BIN(&BIN4) 2000

CALL PGM(QUSCRTUS) PARM( +
&USRSPC /* NAME OF SPACE */
+
&SPCNAM /* EXTENDED NAME ATTRIBUTE */
+
&BIN4 /* SIZE OF SPACE */
+
' ' /* INITIAL FILL CHARACTER */
+
'*ALL' /* PUBLIC AUTHORITY */
+
&SPCTXT /* SPACE TEXT DESCRIPTION */
+
'*YES' /* REPLACE CURRENT SPACE */
+
&APIERR) /* ERROR RETURN FIELD */

CHGVAR %BIN(&KEYCNT) 1
CHGVAR %BIN(&KEYFLD) 1608
/* Fill user space with job information using list API QUSLJOB */
CALL PGM(QUSLJOB) PARM( +
&USRSPC /* NAME OF SPACE */
+
'JOBL0200'/* FORMAT OF JOB INFORMATION */
+
&JOBVAR /* QUALIFIED JOB NAME */
+
&JOBSTS /* JOB STATUS SELECTION */
+
&APIERR /* ERROR RETURN FIELD */
+
'*' /* JOB TYPE SELECTION */
+
&KEYCNT /* NBR OF FIELDS RETURNED */
+
&KEYFLD) /* NBR OF FIELDS RETURNED */

/* Get API list structure using retrieve API QUSRTVUS */
/* This data structure extends 140 bytes from position 1 */
CHGVAR &S 1
CHGVAR %BIN(&STRPOS) &S
CHGVAR %BIN(&LENDTA) 140

CALL PGM(QUSRTVUS) PARM( +
&USRSPC /* NAME OF SPACE */
+
&STRPOS /* RETRIEVE FROM POSITION IN SPACE */
+
&LENDTA /* LENGTH OF STRUCTURE RETRIEVED */
+
&RCVAPI) /* RECEIVING FIELD */

/* Retrieve each list entry using the retrieve API QUSRTVUS */
CHGVAR &LSTPOS %BIN(&RCVAPI 125 4) /* Offset to 1st list
entry */
CHGVAR &LSTCNT %BIN(&RCVAPI 133 4) /* No. of list entries
*/
CHGVAR &LSTSIZ %BIN(&RCVAPI 137 4) /* Size of each list
entry */

/* Increment start position by offset to 1st list entry
*/
CHGVAR &S (&S + &LSTPOS)
CHGVAR %BIN(&LENDTA) &LSTSIZ
RTVLIST:
CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)
IF (&COUNT *GT &LSTCNT) GOTO ENDLIST
CHGVAR %BIN(&STRPOS) &S

CALL PGM(QUSRTVUS) PARM( +
&USRSPC /* NAME OF SPACE */
+
&STRPOS /* RETRIEVE FROM POSITION IN SPACE */
+
&LENDTA /* LENGTH OF STRUCTURE RETRIEVED */
+
&LIST) /* RECEIVING FIELD */

CHGVAR &DEC9 %BIN(&LIST 81 4)
CHGVAR &PID &DEC9
CHGVAR &USRNAM %SST(&LIST 11 10)
CHGVAR &JOBNBR %SST(&LIST 21 6)
SNDPGMMSG MSGID(CPI8859) MSGF(QCPFMSG) MSGDTA('Kill +
job' *BCAT &JOBNBR *TCAT '/' *CAT &USRNAM +
*TCAT '/' *CAT &JOBNAM *BCAT 'PID=' *CAT +
&PID) TOPGMQ(*EXT) MSGTYPE(*STATUS)
CALL QP2SHELL2 ('/QOpensys/usr/bin/kill' '-s' 'kill' &PID)

/* Increment start position by length of list entry */
CHGVAR &S (&S + &LSTSIZ)
GOTO RTVLIST
ENDLIST:
/* Delete user space using space API QUSDLTUS */
CALL PGM(QUSDLTUS) PARM( +
&USRSPC /* NAME OF SPACE */
+
&APIERR) /* ERROR RETURN FIELD */

/* Move pgm messages to previous pgm message queue */
CALL PGM(QMHMOVPM) PARM(' ' '*COMP ' +
X'00000001' '*' X'00000001' X'0000000000000000')

RETURN
ERROR:
IF &NOT1ST RETURN
CHGVAR &NOT1ST '1'
/* Move pgm messages to previous pgm message queue */
CALL PGM(QMHMOVPM) PARM(' ' '*DIAG *ESCAPE ' +
X'00000002' '*' X'00000001' X'0000000000000000')

ENDPGM

Cheers, Peter

-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
On Behalf Of Aaron Bartell
Sent: Friday, 3 October 2008 10:32 a.m.
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] Web server will not shut down

Excellent tip Peter! I am sticking this in my trusty toolbox as I have
had the same issues in the past.

Would you be able to post the source for KILLJOB?

Aaron Bartell
http://mowyourlawn.com

On Thu, Oct 2, 2008 at 4:11 PM, Peter Connell <
Peter.Connell@xxxxxxxxxxxxxxxxx> wrote:

I found it useful enough to write a little cmd KILLJOB JOB(XXX) (an
API can retrieve the PID of any job).
This comes in handy when needing to reboot the server when promoting a

application or when there's trouble.
Since the ENDTCPSVR cmd won't complete if it's on a msg wait, this is
a way to end it unilaterally from an automated job.

-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
On Behalf Of Nathan Andelin
Sent: Friday, 3 October 2008 9:57 a.m.
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] Web server will not shut down

From: Peter Connell
Here is how to instantly terminate the web server via 2 manual steps

from the cmd line.


Sweet, worked like a charm...




--
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list To
post a message email: WEB400@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.


######################################################################
############### This correspondence is for the named person's use
only. It may contain confidential or legally privileged information,
or both. No confidentiality or privilege is waived or lost by any
mistransmission. If you receive this correspondence in error, please
immediately delete it from your system and notify the sender. You must

not disclose, copy or rely on any part of this correspondence if you
are not the intended recipient. Any views expressed in this message
are those of the individual sender, except where the sender expressly,

and with authority, states them to be the views of Veda Advantage. If
you need assistance, please contact Veda Advantage on either
:- Australia 133124 or New Zealand +64 9 367 6200
--
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list To
post a message email: WEB400@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.


--
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list To
post a message email: WEB400@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.

#####################################################################################
This correspondence is for the named person's use only. It may contain confidential or legally privileged information, or both. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this correspondence in error, please immediately delete it from your system and notify the sender. You must not disclose, copy or rely on any part of this correspondence if you are not the intended recipient. Any views expressed in this message are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of Veda Advantage. If you need assistance, please contact Veda Advantage on either :- Australia 133124 or New Zealand +64 9 367 6200

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.