%META:TOPICINFO{author="ChrisBartram" date="1149890237" format="1.1" version="1.1"}% %META:TOPICPARENT{name="Hp3000AccountUserXeqs"}% Here is a job that I use to abort users left on over night. This job lets me exclude job/sessions based on anything in the SHOWJOB output. I have a few different jobs that must stay on. This job will do an ABORTJOB, ABORTIO on the ldev and a NSCONTROL Killsess on the Sessions. It will try only three times and then continue on with the backup of whatever I can get. I have this limit so that if I get a hung session, it won't loop forever. I have this job streamed by the backup job. The backup job waits for a message file which is why the FCOPY at the end of this job. John Zoltak North American Mfg Co
!Job AbortJob,User.Account;HiPri;Pri=Bs;OutClass=,1,1
!
!################################################################
!# See if this is the FIRST Abortjob Stream
!# If so create the AbortChk file initialized
!# to one. Otherwise read the AbortCount from
!# the file and increment it.
!################################################################
!
!File AbortChk,Old;Dev=Disc
!If Lft(HPSTREAMEDBY,8) = "ABORTJOB" Then
! Input AbortCount < *AbortChk
!# make AbortCount into an integer type of variable and add 1
! SetVar AbortCount !AbortCount + 1
!Else
! SetVar AbortCount 1
! Purge AbortChk
! Build AbortChk;Rec=-80,,B,Ascii;Disc=5
!EndIf
!Echo !AbortCount > *AbortChk
!
!################################################################
!# MAKE SURE WE CAN ISSUE OPERATOR COMMANDS!
!################################################################
!
!Opcoms
!
!################################################################
!# Stop the log processes
!################################################################
!
!Continue
!Log OrLog,Stop
!Continue
!Log MmLog,Stop
!Continue
!Log CanLog,Stop
!
!################################################################
!# Generate Master ShowJob File
!################################################################
!
!Purge Showjob,Temp
!Build ShowJob;Rec=-80,,,Ascii;Temp
!File Showjob,OldTemp;Dev=Disc
!Showjob Exec;*Showjob
!
!################################################################
!# Copy to ShowJob Message File For First Pass
!################################################################
!
!Purge ShowjobM,Temp
!Build ShowjobM;Rec=-80,,,Ascii;Temp;Msg
!File ShowjobM,OldTemp;Dev=Disc
!
!FCopy From=*Showjob;To=*ShowjobM
!
!################################################################
!# Re-Build Master ShowJob File w/o non-abortables
!################################################################
!
!Purge Showjob,Temp
!Build ShowJob;Rec=-80,,,Ascii;Temp
!File Showjob,OldTemp;Dev=Disc
!
!################################################################
!# Read Message File - Copy back to Showjob File
!################################################################
!
!While FInfo("ShowjobM",19) > 0
! Input User < *ShowjobM
! If Lft(User,1) = "#" Then
! SetVar Counter 0
! If Str(User,19,4) = " 20" Then
! SetVar Counter Counter + 1
! EndIf
! SetVar Counter Counter + Pos("MCP.LIB", User)
! SetVar Counter Counter + Pos("SUPRVISR,", User)
! SetVar Counter Counter + Pos("MTRUCK0,", User)
! SetVar Counter Counter + Pos("MAINTJOB,", User)
! SetVar Counter Counter + Pos("NA.COPY", User)
! SetVar Counter Counter + Pos("NOABORT,", User)
! If Counter = 0 Then
! Echo Will Abort ![RTrim("!User")]
! Echo ![RTrim("!User")] >> *Showjob
! Else
! Echo Will NOT Abort ![RTrim("!User")]
! EndIf
! EndIf
!EndWhile
!
!################################################################
!# Now, I have a Showjob File of only the
!# Jobs and Sessions that are to be Aborted
!################################################################
!
!################################################################
!# Copy Showjob to Message File for Aborts
!################################################################
!
!Purge ShowjobM,Temp
!Build ShowjobM;Rec=-80,,,Ascii;Temp;Msg
!File ShowjobM,OldTemp;Dev=Disc
!
!FCopy From=*Showjob;To=*ShowjobM
!
!While FInfo("ShowjobM",19) > 0
! Input User < *ShowjobM
! SetVar Session RTrim(Lft(User,7))
! SetVar LDev RTrim(Str(User,19,4))
! Continue
! Abortjob !Session
! If Lft(Session,2) = "#S" Then
! Continue
! AbortIo !LDev
! EndIf
!EndWhile
!
!################################################################
!# Wait awhile for J/S's to Abort
!################################################################
!
!Pause 60
!
!################################################################
!# Copy to Message File for KILLSESS Pass
!################################################################
!
!Purge ShowjobM,Temp
!Build ShowjobM;Rec=-80,,,Ascii;Temp;Msg
!File ShowjobM,OldTemp;Dev=Disc
!
!FCopy From=*SHowjob;To=*ShowjobM
!
!While FInfo("ShowjobM",19) > 0
! Input User < *ShowjobM
! SetVar Session RTrim(Lft(User,7))
! ErrClear
! Tell !Session
! If CiError = 0 Then
! Continue
! NSControl KillSess=!Session
! EndIf
!EndWhile
!
!Showjob
!File Lp;Dev=CsLaser
!Print Showjob;Out=*Lp
!
!################################################################
!# See if we're still logging
!################################################################
!
!SetVar StillLogging False
!ErrClear
!Continue
!ShowLogStatus OrLog
!If CiError = Ok Then
! SetVar StillLogging True
!EndIf
!
!ErrClear
!Continue
!ShowLogStatus MmLog
!If CiError = Ok Then
! SetVar StillLogging True
!EndIf
!
!ErrClear
!Continue
!ShowLogStatus CanLog
!If CiError = Ok Then
! SetVar StillLogging True
!EndIf
!
!################################################################
!# If the log processes are still running, then we need to try
!# abortjob again. But if we've tried this three times, just
!# skip it and continue with backup so we don't loop forever.
!################################################################
!
!If StillLogging Then
! If AbortCount < 3 Then
! Stream AbortJob.Job
! Eoj
! EndIf
!EndIf
!
!FCopy From=MsgDummy;To=Msg
!
!Eoj
-- Main.ChrisBartram - 09 Jun 2006