AS/400 Command

55 pts.
Tags:
AS/400 commands
AS/400 jobs
Hey please let me know, if there is any single AS/400 command to kill all the jobs (Inactive/Active) in a given AS/400 Environment

Answer Wiki

Thanks. We'll let you know when a new response is added.

This site might be helpful.

Here is a script from another site that uses the above:

USE MSDB

SET NOCOUNT ON

DECLARE @JOB_NAME VARCHAR(255)

IF OBJECT_ID('TEMPDB..#ENUM_JOB') > 0
DROP TABLE #ENUM_JOB

CREATE TABLE #ENUM_JOB (
JOB_ID UNIQUEIDENTIFIER,
LAST_RUN_DATE INT,
LAST_RUN_TIME INT,
NEXT_RUN_DATE INT,
NEXT_RUN_TIME INT,
NEXT_RUN_SCHEDULE_ID INT,
REQUESTED_TO_RUN INT,
REQUEST_SOURCE INT,
REQUEST_SOURCE_ID VARCHAR(100),
RUNNING INT,
CURRENT_STEP INT,
CURRENT_RETRY_ATTEMPT INT,
STATE INT
)
INSERT INTO #ENUM_JOB
EXEC MASTER.DBO.XP_SQLAGENT_ENUM_JOBS 1,GARBAGE

DECLARE job_cursor CURSOR LOCAL FOR
SELECT j.name FROM #ENUM_JOB EJ
INNER JOIN MSDB..SYSJOBS J
ON J.JOB_ID = EJ.JOB_ID
AND EJ.RUNNING = 1
INNER JOIN MSDB..SYSCATEGORIES C
ON J.CATEGORY_ID = C.CATEGORY_ID
AND C.NAME = 'DATABASE MAINTENANCE'

OPEN job_cursor

FETCH NEXT FROM job_cursor
INTO @JOB_NAME

WHILE @@FETCH_STATUS = 0
BEGIN

EXEC sp_stop_job @job_name = @JOB_NAME

-- Get the next job.
FETCH NEXT FROM job_cursor
INTO @JOB_NAME
END
CLOSE job_cursor
DEALLOCATE job_cursor

SET NOCOUNT OFF

***************************************************
Good Luck!
-Flame

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Tpinky
    Hello,,, If you are trying to end all jobs, users, etc... and go into a restricted state...you could just do a ENDSYS command. This will end all system jobs as well as all subsystems except QCTL which is your controlling subsystem. Hope this helps... TPinky
    4,165 pointsBadges:
    report
  • slack400
    Flame truely is playing with fire. I agree with TPINKY. If you're looking to end all jobs you you endsys. But you have to do this from the console or by submitting the command through QCTL. You can always submit a PWRDWNSYS as well if you're going to a total shutdown.
    2,705 pointsBadges:
    report
  • Gilly400
    Hi, One thing to bear in mind with ENDSYS and QCTL - QCTL may *not* be your controlling subsystem - this depends on how your system is set up. Normally QCTL is used as the controlling subsystem - probably 8 or 9 times out of 10 this will be the case, but some sites use QBASE or their own subsystem definitions as the controlling subsystem. You can check which subsystem is the controlling subsystem by :- DSPSYSVAL QCTLSBSD If you have a console device, it will normally run in this subsystem. You *may* be able to transfer your job to this subsystem using the TFRJOB command to the relevant job queue. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following