Scheduling workbench jobs with a batch file and windows task scheduler

jstan
jstan Contributor

Hi, one of the questions I got yesterday was around scheduling workbench or other jobs using windows scheduler vs. the scheduler built into workbench.  

  • See my reply for the solution.
Tagged:

Best Answer

  • jstan
    jstan Contributor
    Answer ✓
    • Create a bat file to call the jobs. 
      • They will run in the order that you list them, so you can put multiple jobs in one batch file.  For those not familiar with batch files, it is basically a .txt file with .bat as the file type.  I recommend using Notepad++ to create them, but you can also use Windows Notepad.
      • Command line: "C:\Program Files\Domo\Workbench\wb.exe" run-Job -s daltile.domo.com -j 495
        • In here you are calling the program workbench and running job 495.  The workbench job ID can be found in workbench on the overview of the job (click on the job name).
        • If you want another job, on the next line, just repeat: "C:\Program Files\Domo\Workbench\wb.exe" run-Job -s daltile.domo.com -j 496
    • Create a task in the windows task scheduler.
      • If this is on a server, I recommend on the general tab of the task to set SYSTEM as the user account when running the task and check run whether user is logged in or not and run with highest privileges.
      • Set the trigger.  Usually this will be a certain time of the day/week/month.  You can have multiple triggers.
      • Set the action: This is where you will "Start a program" and reference the bat file that you created in the first step.  You can have multiple actions to call bat files one after another.
      • Other settings: if the job fails, you can have it retry.  You can also set a timeout so the job doesn't run too long.

    So you can have multiple workbench jobs in one bat file and you can have multiple bat files in a single task in windows scheduler.  

     

    Once you test your first bat file, you can get creative and start writing out a log that you can then upload to Domo.  Below is an example where we have the start and end times for the job written to a text file.  There is another job in workbench that will upload the text file to Domo every 15 minutes.

     

    • (echo Started Job Win_WMS_MRZ 495 %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2% %time:~0,2%:%time:~3,2%:%time:~6,2%) >> C:\ProgramData\Domo\Workbench\Groups\batch_log.txt
    • "C:\Program Files\Domo\Workbench\wb.exe" run-Job -s daltile.domo.com -j 495
    • (echo Completed Job Win_WMS_MRZ 495 %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2% %time:~0,2%:%time:~3,2%:%time:~6,2%) >> C:\ProgramData\Domo\Workbench\Groups\batch_log.txt

    Hope this helps. 

     

    Thanks,

    Josh

     

     

Answers

  • jstan
    jstan Contributor
    Answer ✓
    • Create a bat file to call the jobs. 
      • They will run in the order that you list them, so you can put multiple jobs in one batch file.  For those not familiar with batch files, it is basically a .txt file with .bat as the file type.  I recommend using Notepad++ to create them, but you can also use Windows Notepad.
      • Command line: "C:\Program Files\Domo\Workbench\wb.exe" run-Job -s daltile.domo.com -j 495
        • In here you are calling the program workbench and running job 495.  The workbench job ID can be found in workbench on the overview of the job (click on the job name).
        • If you want another job, on the next line, just repeat: "C:\Program Files\Domo\Workbench\wb.exe" run-Job -s daltile.domo.com -j 496
    • Create a task in the windows task scheduler.
      • If this is on a server, I recommend on the general tab of the task to set SYSTEM as the user account when running the task and check run whether user is logged in or not and run with highest privileges.
      • Set the trigger.  Usually this will be a certain time of the day/week/month.  You can have multiple triggers.
      • Set the action: This is where you will "Start a program" and reference the bat file that you created in the first step.  You can have multiple actions to call bat files one after another.
      • Other settings: if the job fails, you can have it retry.  You can also set a timeout so the job doesn't run too long.

    So you can have multiple workbench jobs in one bat file and you can have multiple bat files in a single task in windows scheduler.  

     

    Once you test your first bat file, you can get creative and start writing out a log that you can then upload to Domo.  Below is an example where we have the start and end times for the job written to a text file.  There is another job in workbench that will upload the text file to Domo every 15 minutes.

     

    • (echo Started Job Win_WMS_MRZ 495 %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2% %time:~0,2%:%time:~3,2%:%time:~6,2%) >> C:\ProgramData\Domo\Workbench\Groups\batch_log.txt
    • "C:\Program Files\Domo\Workbench\wb.exe" run-Job -s daltile.domo.com -j 495
    • (echo Completed Job Win_WMS_MRZ 495 %DATE:~-4%-%DATE:~4,2%-%DATE:~7,2% %time:~0,2%:%time:~3,2%:%time:~6,2%) >> C:\ProgramData\Domo\Workbench\Groups\batch_log.txt

    Hope this helps. 

     

    Thanks,

    Josh

     

     

  • jcsrt
    jcsrt Member

    Hi,

     

    I followed all the steps described above and every time I try to run it I get this error.

    Here is the code I'm using inside the batch file:

    start "C:\Program Files\Domo\Workbench\wb.exe" "run-Job -s daltile.domo.com -j 159"

    Any thoughts?

  • Try removing the quotes around the "run-job" portion. Weirdly for me that works only having the path in quotes. 

     

     

This discussion has been closed.