How to implement a throttle for scheduled tasks?
i'm trying implement gate or throttle on batch queue. want scheduled tasks block , let 1 task proceed @ time.
presently i'm using python call kernel32.openprocess convert pid (process id) handle , using kernel32.waitforsingleobject wait process exit. timeout every 15 minutes print debug statement indicating i'm still waiting on process , try waiting again.
if pid not exist because process exited, error , print out in debug statement , stop waiting , start executing desired task.
if pid existed , start waiting on , go past midnight , process i'm waiting (apparently) gets new pid, erroneously continue waiting forever.
so, can do?
perhaps translate python powershell , list of processes , pids , if pid no longer exists, should no longer hang. new pid (assuming windows indeed replacing pids @ midnight) , wait on that. can that? how?
can me started powershell script waits on process exit , times out every 15 minutes , checks see if pid still exists every 15 minutes? if pid no longer exists, have way of getting new pid. if not possible, poll every 15 minutes see if file exists , if not, assume previous process has deleted , ok proceed.
thanks
siegfried
siegfried heintze
hi there,
trying achieve possible through use of eventing in powershell.
can create timer object , later register objectevent....a useful guide can found below :
http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/16/use-asynchronous-event-handling-in-powershell.aspx
for getting pid process , can use get-process cmdlet , pid process. below:
#for ex- process name lsass $process = get-process -name lsass #store process object in variable $process.id #this give pid process
hope helps :)
knowledge power{shell}.
Windows Server > Windows PowerShell
Comments
Post a Comment