15 Replies Latest reply: Sep 10, 2014 5:49 AM by Jonathan Dienst RSS

    Schedule reload with.bat

    Laura Sébille

      Hello everyone,

       

      Because I have some trouble with scheduled reload on QMC, i would like to schedule a reload with a bat file (and then using Windows task sheduler).

       

      The thing is I have dependant tasks. 4 applications must be reloaded one after another.

       

      So far, I have just writen

      "C:\\Program Files\Qlikview\Qv.exe" /r "\\blabla\App_1.qvw"

      "C:\\Program Files\Qlikview\Qv.exe" /r "\\blabla\App_2.qvw"

      "C:\\Program Files\Qlikview\Qv.exe" /r "\\blabla\App_3.qvw"

      "C:\\Program Files\Qlikview\Qv.exe" /r "\\blabla\App_4.qvw"


      But even if one fails, the following one are reloaded and I don't want that.


      How can I specify that I want to stop the execution of the bat file  if one task fails ?

       

      Thanks for your help

        • Re: Schedule reload with.bat

          From what I know , that is not possible.

          There is no enginee to monitor if it fails and to halt it.

          • Re: Schedule reload with.bat

            Hi Laura,

             

            You can but in a roundabout way.

             

            If you turn on logging in the Qlikview document  - this can create a logfile of the script that you can check in your batch script.

            The batch syntax is "findstr"

             

            EG:

             

            Rem *** Check the logfile for errors by doing a string search
            type "BatchExample_loading.qvw.log" | findstr /I /C:"Error:"

             

            Rem ***if the text "Error" is found, output to a file, othrwise some other action
            if %errorlevel%==0 (
            echo %date% %time% Error occurred - Log lines found are: >ErrorDetails.txt
            type "BatchExample_loading.qvw.log" | findstr /I /C:"Error:">>ErrorDetails.txt

            ) else (

            [another action!]

            ......

             

            Remember not to include the date in the logfile name when you set this as an option in QlikView. Otherwise the script will not find the file!

             

            Erica

            • Re: Schedule reload with.bat
              Colin Albert

              Scheduling tasks to run on successful completion of another task is straightforward on the QMC.

              This will stop the task when one step fails

              The QMC also supports sending email alerts when jobs fail (or succeed).

               

              Isn't it simpler to resolve the QMC issues. rather than creating a workaround that is outside the control and logging of QV server?

              • Re: Schedule reload with.bat
                Massimo Grossi

                if you don't want too use batch may be you can do in qlik, use a file with 4 lines, one for App_n and the status

                 

                when the App_n starts

                     set the status KO

                     check status of previuos app (if any), if not OK exit

                when it ends, set status (OK/KO)

                  • Re: Schedule reload with.bat
                    Laura Sébille

                    Hi Massimo,

                    You mean create a special application to reload the 4 other ones ?

                     

                    If so, how do I write in the script "reload" app1 ?

                     

                    And then I guess I don't need a variable with a status because a Qlikview reload always stops when an there is an error ?

                     

                     

                    Thanks

                      • Re: Schedule reload with.bat
                        Marcus Sommer

                        If the update-logic per server worked fine unless proper mails for failure/success it could be an alternativelly to use this functionality and take a second independent batch-line which checks the updates (filetime) and send the mails.

                         

                        Then all methods have disadvantages and require a lot of effort to recognize and handle them, for example my preferred method with open + reload per vbs in a batch-qvw will stop by any error and hang if a ftp-server or a database didn't response. All error-methods to handle these cases didn't work well so that I really need a second etl-line which checked the first line and closed them by any error/timeout and started the first line again by skipping the previous update-tasks. For me it was too much effort and so I live with some shortcomings ...

                         

                        - Marcus

                    • Re: Schedule reload with.bat
                      Laura Sébille

                      Hello everyone,

                       

                      I have managed to do it using Erica's solution :

                      EG:

                       

                      Rem *** Check the logfile for errors by doing a string search
                      type "BatchExample_loading.qvw.log" | findstr /I /C:"Error:"

                       

                      Rem ***if the text "Error" is found, output to a file, othrwise some other action
                      if %errorlevel%==0 (
                      echo %date% %time% Error occurred - Log lines found are: >ErrorDetails.txt
                      type "BatchExample_loading.qvw.log" | findstr /I /C:"Error:">>ErrorDetails.txt

                      ) else (

                      [another action!]

                      ......

                       

                       

                       

                      Now I face another problem. I have tested it with an application which fails.  The thing is with my .bat, Qlikview opens up and performs the reload and when there is an error in the script, a pop up appears  (for example : table not found) and then, I have to manually click on "Ok" so the batch can continue... Otherwise, it stays like this..

                       

                      And if I have a sheduled task at 01:00 that fails and another task at 02:00, the second one cannot start because the first one is "blocked"  (and the app1 is opened).

                       

                      What can I do about that ?

                       

                      thanks again for your help

                        • Re: Schedule reload with.bat

                          Hi Laura

                           

                          Set the system variable  errormode to 0 in the script in your QVW

                          ErrorMode = 0;

                          This will continue the script if an error is found wihtout having to click on any dialogues.

                           

                          Erica

                            • Re: Schedule reload with.bat
                              Laura Sébille

                              Thank you Erica !

                               

                               

                              I have another problem. I cannot find the proper syntax for the if, else ....

                               

                              I have :

                               

                              if %errorlevel%==0 (

                              Code to send email

                              )

                              else

                              ([

                              "C:\\Program Files\Qlikview\Qv.exe" /r "Referentiel\Referentiel_MAITRE.qvw"

                              ])

                               

                               

                              If my first application fails, I receive an email and then the batch stops so it's okay.

                              But if my first application doesn't fail, I don't receive an email (which is ok) but  the second application (in the else) doesn't start reloading...

                               

                              I have also tried :

                               

                              if %errorlevel%==0 ; then

                              Code_email

                              else

                              "C:\\Program Files\Qlikview\Qv.exe" /r "\Referentiel\Referentiel_MAITRE.qvw"

                              fi

                               

                               

                              This time the second app starts but I always receive an email (even if there is no error in the first app)

                               

                              Does someone see what's wrong in my piece of code ?

                               

                              Thanks again.

                               

                              Laura