|
-
Feb 4th, 2012, 12:27 PM
#1
USe SCHTASKS to run a task - holding others till this one is done
I want to run a series of .BAT files - but only have ONE RUNNING at a time. If I have two or three .BAT files I want them queued up so that only one runs - then the next - and so on.
I could do this with other O/S task management tools.
I was going to code my own methods - seeing if a .BAT was running - holding the others - etc. But the handshaking on this operation could be painful to test...
I was hoping the SCHTASKS tool in windows would be my answer - but I'm not seeing options to do this.
Anyone have any ideas??
-
Feb 4th, 2012, 01:49 PM
#2
Re: USe SCHTASKS to run a task - holding others till this one is done
Well - here is my thoughts on home growing a solution - anyone willing to read through these steps and offer opinions or options - I would really appreciate it!
ASP.Net web service process-----------------
With application lock (in asp.net application lock makes sure only one web page is getting this "function" at a time)
...Insert into ReportProcess_T table with report request / username / desired visual output filename
...ReportCounter set to Identity Column value returned
...Check if STAGING folder contains Busy.txt
......If Not then create Busy.txt with contents of ReportCounter (and sets boolean to "run batch file")
...Create Report_{ReportCounter}.Bat
...If "run batch file" is true then Process.Start .Bat file
End Lock
----------------------------------
Batch file processing
Batch file runs amcReport.exe and creates awcOutput.pdf (this could take from seconds to several minutes)
...when done it does a Process.Start on awcCleanup.exe
awcCleanup.exe processing
...Renames awcOutput.pdf based on contents of Busy.txt (awcReport_{reportCounter}.pdf}
...and moves to STORAGE folder
...Deletes Report_{ReportCounter}.bat in parent folder
...If any other Report_*.bat files exist then it does a Process.Start on the next one in sequence
......otherwise
...Deletes Busy.txt
??Here is the problem - during the microseconds it takes to "check" and then "delete" (those last two steps)
the ASP.Net web service could have seen the Busy.txt file and decided to NOT SUBMIT
I'm thinking of adding pauses to "double-check" - but seems to be a hack!
-
Feb 5th, 2012, 12:48 AM
#3
Re: USe SCHTASKS to run a task - holding others till this one is done
Why not run a batch file which executes the other batch files in sequence?
Code:
batch1.bat && batch2.bat && batch3.bat
Or am I missing something?
-
Feb 5th, 2012, 08:57 AM
#4
Re: USe SCHTASKS to run a task - holding others till this one is done
I can only have one batch file running at a time - but the requests to run them are not necessarily consecutively happening.
One might come in - run - finish - and that is it. When the next one comes in the web service can start it - because the queue is free.
If ten come in all at once I have to somehow keep them from stepping on each others feet. Those ten requests are coming via a web service - so they "don't know about each other".
Other mainframe batch queue systems I've worked with permitted all kinds of control such as "one a time"...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|