I’m executing KNIME workflows using batch file, as I need to schedule them on servers, using Task Scheduler. I have read a lot on this topic, but haven’t found a good solution yet. Everything executes fine, except that KNIME does not quit/close once the execution is completed. I have removed “-noexit” option in my batch file, but did not help. I was wondering, is it possible to make a node itself eg. Quit KNIME node, because I recently saw a video where they had used a node called “Quit WebDriver”. The QuitKNIME node, can be placed as the last node of the workflow, so when this node is reached, it will close KNIME, something similar to Close or Quit methods in other programming languages. I’m new to KNIME, so hoping the experts out there can weigh in. Even if some kind of script that will quit KNIME that can be placed at the end? Thanks.
Hi @kris1234 and welcome to the Knime Community.
Without the -noexit option, it should close.
Can you show us your command line that you are executing?
The really ugly way to do this, perhaps the only way, is to force the application to do a hard exit using a Java script node. Upon executing this script the application will immediately terminate. It is brutal and doesn’t allow KNIME to save the workflow or do any of its usual clean-up activities, so not recommended. When you restart the workflow there will be an auto-saved copy of the workflow and the original copy, you will need to determine which you want to keep. If you are running this workflow on the server then you may find that KNIME generates multiple copies of the workflow that you need to expunge every so often to prevent the disk from filling up.
Health warning given, here is a potential solution.
The demonstration workflow includes three nodes at the end of your workflow:
- A node to save the workflow. This is optional, it depends whether you want to keep intermediate calculations.
- A
wait...
node to ensure that all buffers are flushed before doing a hard exit. I’ve set five seconds, but you may want to adjust this to ensure that all data is flushed and saved before you exit. - A Java Edit Variable containing the System.Exit(0) code to terminate the KNIME application.
The Java Edit Variable contains the following code (highlighted in red box). IMPORTANT! You need to make sure that the script is set to run during node execution and NOT during node configuration. If you have the option set to node configuration then KNIME will terminate when you close the dialogue box. IMPORTANT! make sure that you save the workflow BEFORE you test the workflow as the application will close without saving any changes that you have made.
It’s ugly. It’s not recommended. Use at your own risk.
Hope that helps.
Thanks @DiaAzul for the detailed explanation. I do see pros and cons to it. I will keep this in back pocket and use as a last resort if needed. Thanks!
@bruno29a Below is my line:
cd "C:\KNIME\KNIME-V4.5.1\kap\bin"
.\knime.exe -consoleLog -nosplash -nosave -reset -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir=“C:\KNIME\KNIME-V4.5.1\kap\workspace\WFTest”
Basically, the workflow runs successfully. It has an Excel write node at the end, so I can check the Excel file to validate successful run. After the run, I don’t think it should take more than few minutes (if at all) to close KNIME, but even after half hour, I see KNIME is open in task manager. I do know this was the only workflow that was run, so there is no chance any other workflow is running or was run. Thanks for looking into it!
Thanks for the command line @kris1234 .
Can you please run this command instead?
"C:\KNIME\KNIME-V4.5.1\kap\bin\knime.exe" -consoleLog -nosplash -nosave -reset -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir="C:\KNIME\KNIME-V4.5.1\kap\workspace\WFTest"
@bruno29a - wow that worked. Removing the “cd” at the beginning did the trick for me. Thank you very much!!
Hi @kris1234 , no problem, happy to help.
The Knime command line is able to close the CLI window once it is done. However, when running the “cd” command, it’s no longer a window only for Knime, that is why it does not have control anymore on the CLI window.
At this point, you may need to configure the batch file itself to close itself at the end.
However, you do not need to run “cd”, since you do not need to excute the workflow within the folder that contains the Knime executable. You can just run at from the full path in the end as you found out.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.