55 pts.
 AS/400 Command
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

Software/Hardware used:
ASKED: November 6, 2008  1:20 PM
UPDATED: November 11, 2008  4:30 PM

Answer Wiki:
This <a href="http://msdn.microsoft.com/en-us/library/aa260308(SQL.80).aspx">site</a> 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
Last Wiki Answer Submitted:  November 6, 2008  4:11 pm  by  Flame   14,895 pts.
All Answer Wiki Contributors:  Flame   14,895 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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 pts.

 

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,680 pts.

 

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,625 pts.