Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Batch file to run processes asynchronously

  • 31-03-2011 10:04AM
    #1
    Registered Users, Registered Users 2 Posts: 7,541 ✭✭✭


    Morning all,

    My experience of writing batch scripts is limited to .bat files calling one or two processes synchronously. So looking to get some advice on something more complex.

    Environment is Windows Server 2008 and it has Powershell 2 installed if that's needed.

    What I'm looking to do is to create a batch file that can be called in a scheduled task.

    This batch file will in turn call several other batch files that must all run asynchronously (i.e. in parallel). These asynch batchfiles will contain a process that will extract data from an datasource into a .csv file and then sftp that .csv to a remote server. I'd like to log the output from each of these asynch batch files(i.e. success/error messages) to a text file. The main batch should also log its output to a text file.

    So I'm guessing I chould do something like:
    Main.bat:
    start async1.bat >> c:\some dir\output1.log
    start async2.bat >> c:\some dir\output2.log
    etc
    

    Is it as simple as that?? Or am I missing somthing?

    Also if I wanted some logic that will determine if the async batches ran correctly how do I do that? Analyse the output for key words (i.e. Error! Failure, etc) and act appropriately?

    Any advice welcome! Thanks


Advertisement