# Start a Workflow, e. g. a database query, after a certain time

**URL:** <https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287>\
**Category:** KNIME Analytics Platform\
**Created:** [January 28, 2021, 12:33pm UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287 "2021-01-28T12:33:29Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [February 2, 2021, 10:06am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/21 "2021-02-02T10:06:32Z")

</div>

@USCHUKN1ME you can put a Loop End at the end where what you want to do is finished. If you do not want to collect data but just to end the loop you could use:

> **[Variable Loop End](https://hub.knime.com/knime/extensions/org.knime.features.base/latest/org.knime.base.node.meta.looper.variable.end.LoopEndVariableNodeFactory)**
>
> Node collecting variables created in a loop. This node closes a loop but does not aggregate data created in the loop but only variables. It can be used to clos…

Then I would encourgae you to [learn about Loops](https://hub.knime.com/mlauber71/spaces/Public/latest/_loops_and_flow_variables_knime?u=mlauber71) 🙂

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 2, 2021, 10:30am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/22 "2021-02-02T10:30:05Z")

</div>

@mlauber71 🙂 thank you !

I set a loop-end node to this position:  
 ![Loop-End-Node-Platzierung](https://forum-cdn.knime.com/uploads/default/original/3X/d/7/d75df9eb08e604607a1a6003b9257894ba76ebf8.png)

I guess it was wrong 😬 an di have to use the Variable Loop End Node?!

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 2, 2021, 10:32am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/23 "2021-02-02T10:32:40Z")

</div>

@mlauber71

Some of the links are “dead”

 ![2021-02-02 11_32_07-Page not found _ KNIME](https://forum-cdn.knime.com/uploads/default/original/3X/2/5/25e01906a2a0ec323e9a99942b118e25f46e70aa.png)

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [February 2, 2021, 11:31am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/24 "2021-02-02T11:31:53Z")

</div>

Loop end would collect the data that comes its way. Variable Loop End would just end the loop and would collect Flow Variables (so you could continue some other tasks afterwards or hand down information from within the loop) - the data handling would have to be done separately within the loop (save to database or disk).

In your screenshot the loop end is within the component. Question is if you want that you would want the component to finish. So it might be better to place a Loop End outside.

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 2, 2021, 11:54am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/25 "2021-02-02T11:54:19Z")

</div>

@mlauber71

ok understand.  
If I patch the node inside the component, it “only” terminates the component but not the workflow.

But the component is also part of the workflow - where do I set the loop end node correctly then?

![Loop wo platzieren](https://forum-cdn.knime.com/uploads/default/original/3X/d/9/d9fcafe41c2cbe04a5a7ea4355f98cff941a5483.png)

🤔

greetings

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [February 6, 2021, 1:07pm UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/26 "2021-02-06T13:07:03Z")

</div>

@USCHUKN1ME you will have to have everything that should happen within _one_ iteration of a Loop within the loop. If you have a more complicated setting that might involve some trial and error. And you will have to make sure to ‘reset’ scything you want to be new/resetted at the beginning of each iteration. If you want to transfer information from one loop iteration to the next there are the Recursive Loops (which I still somewhat struggle to grasp 🙂 ).

> **[Recursive Looping – iris](https://hub.knime.com/knime/spaces/Examples/latest/06_Control_Structures/04_Loops/07_Example_for_Recursive_Looping)**
>
> This workflow demonstrates the recursive loop nodes for calculating the sum from 1 to n

If you want to store intermediate information you can -well- save that as a table and read it back in the next iteration (not the most elegant of solutions).

> **[kn\_example\_recursive\_loop\_storage\_week\_forecast – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_recursive_loop_storage_week_forecast)**
>
> use a very simple loop to make a forecast prediction. Also use temporary table to store information in a loop an read it back use a very simple loop to make a …

Then I would suggest you familiarise yourself with the concepts of Loops and Flow variables in general

> **[A meta collection about Loops, Paths and Flow Variables in KNIME (and some...](https://hub.knime.com/mlauber71/spaces/Public/latest/_loops_and_flow_variables_knime)**
>
> A meta collection about Loops, Paths and Flow Variables in KNIME (and some ZIP files) Start with KNIME's Flow Control Guide https://docs.knime.com/latest/analy…

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 8, 2021, 9:48am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/27 "2021-02-08T09:48:58Z")

</div>

@mlauber71 thank you, i guess it isn´t easy 🙈

**PS: Many of the links doesn´t work!**

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 8, 2021, 4:24pm UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/28 "2021-02-08T16:24:39Z")

</div>

@mlauber71 hello again

The problem for a beginner, with such large workflows, is to understand why Node A,B,C,… are required for the loop nodes or perform other functions.

 ![Example Loop by mlauber](https://forum-cdn.knime.com/uploads/default/original/3X/1/f/1f2a74f2c7f31d9a60ad0d75a0b57ffe4ad5e5f2.png)

**Loop Start**  
 ![Example Loop by mlauber-LOOP-Start](https://forum-cdn.knime.com/uploads/default/original/3X/5/8/58a8baa011d414f68c6f6e3a26b3551dfe5828b1.png)

**Loop End**

 ![Example Loop by mlauber-LOOP-END](https://forum-cdn.knime.com/uploads/default/original/3X/8/d/8daba4a87f5d37dead7af1250fcf7deb87f3d503.png)

How to arrive at this configuration is not (yet) revealed to me!

I always think of a loop node an _if… then… else_ or a _for… to_ loop.

But I think that’s wrong!

greetings

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [February 9, 2021, 7:29am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/29 "2021-02-09T07:29:29Z")

</div>

If then else is another matter and there are [other nodes for that](https://hub.knime.com/search?q=kn_example_%20switch&type=Workflow).

With loops there are tow important End nodes.

- one would collect i a KNIME table whatever output is there (you can allow changing structures)
- the variable Loop end would just end whatever is within the loop and just store flow variables with possible informations in them

My impresssion is that you might want to take a step back to the drawing board and make a plan what you want to achieve and familiarize yourself with some KNIME nodes and concepts mentioned in this thread.

Regarding automation / scheduling you have these options

- KNIME server (possibly via AWS)
- Batch mode via CRON or Task Manager
- a wait construction I showed above

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 9, 2021, 10:40am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/30 "2021-02-09T10:40:00Z")

</div>

@mlauber71

actually, it’s relatively simple.  
I have a **database query** and a workflow behind it (_end with output of a graphic/dashboard + sending an email_). I want to **restart the database query + workflow** at **three predefined times** without having to manually reset and rerun the individual nodes.

**Start:**  
 ![Datenbankworkflow Anfang](https://forum-cdn.knime.com/uploads/default/original/3X/9/3/93e24b4ea48f54e3eaab12e5d3f22f9009e6ab8d.png)

**Workflow after DB Query Node**

 ![Datenbankworkflow Workflow nach DB Query](https://forum-cdn.knime.com/uploads/default/original/3X/4/d/4d593384b5177c925c02ba2627f74d4cabc03f6a.png)

**End of the workflow in the component**

 ![Datenbankworkflow Component Inhalt](https://forum-cdn.knime.com/uploads/default/original/3X/4/2/427b4dbf99eb16fac111836e1140e691fa19cf05.png)

**My Question?**

Which loop node is the right one for this ?  
Is it the Wait Node with a Table creator Node before?  
🤔

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 9, 2021, 10:48am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/31 "2021-02-09T10:48:12Z")

</div>

> [@mlauber71](#):
>
> a wait construction I showed above

Sorry - which one do you mean?

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 16, 2021, 5:03pm UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/32 "2021-02-16T17:03:45Z")

</div>

**CRASHED** 😑

 ![BAT-Auftragsbestand_C__Program Files_KNIME_knime.exe_ -consoleLog -nosplash -reset -application or](https://forum-cdn.knime.com/uploads/default/original/3X/6/8/68a4843b9ebbd0804e1dd82ddee83c7103182635.png)

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 18, 2021, 5:09pm UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/33 "2021-02-18T17:09:37Z")

</div>

Next try 😜, again via the **WAIT node**. Have now built something about  
the task scheduling of Windows, which Starts a batch file which creates  
a simple text file and overwrites each time. I configured the WAIT node  
in KNIME _to wait for the modification of a file_ and then execute it. That worked.

I try to start the subsequent wokflow behind the WAIT node via a LOOP node. 🤔

Stupid about the WAIT node is, that it is only executable once and cannot be controlled with it.

**Or is there any way to control the WAIT-Node?**

![WAIT-Node](https://forum-cdn.knime.com/uploads/default/original/3X/1/b/1b219f39ccc4c86f368d89e64f907eef120aed98.png)

 ![WAIT-NODE-Config-waiting-modification](https://forum-cdn.knime.com/uploads/default/original/3X/3/1/314363662daf7f405e0c18fdf6c7cddfed60c4c5.png)

If anyone here has a bright idea I am very grateful for a tip.

greetings

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [February 18, 2021, 6:23pm UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/34 "2021-02-18T18:23:22Z")

</div>

My suggestion would still be to try and put the wait node within the loop and create the times of a day you want it to be executed in a table to control when the loop would continue.

You might want to download the example and maybe try to adapt it so we could try and discuss what you would need.

> **[use the Wait node to execute a database query at fixed times – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_db_wait_execute)**
>
> use the Wait node to execute a database query at fixed times Please note: If the time of day has passed when the workflow reaches the Wait node it will wait un…

You could of course also use a task manager to start a batch file or even start it at several times a day which in any case would need a computer to run continuously which also would be true if you just let the knime workflow wait with the loop.

If you use the batch mode it might be necessary to use a different knime-workspace if you want to use the machine at the same time.

The knime server in a dedicated server would be another option of course.

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 19, 2021, 3:19pm UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/35 "2021-02-19T15:19:56Z")

</div>

First @mlauber71: Thank you !

My first question about your case workflow would be:  
What is the function of add\_seconds?

 ![WAIT-Node-mit-flow-Variablen-MLauber](https://forum-cdn.knime.com/uploads/default/original/3X/b/8/b80757011987184616f16d0765623a2431d5a07e.png)

I’m trying to figure out all the functions of your workflow…

Greetings

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [February 21, 2021, 6:12pm UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/36 "2021-02-21T18:12:48Z")

</div>

@USCHUKN1ME I tried to build a system you might be able to expand and use.

The idea is to have a workflow that would iterate a number of times (_v\_number\_of\_intervals_) with a set interval (of seconds) between (_v\_seconds\_interval_) them. The workflow looks for a _trigger\_file.csv_ if this file has changed from the last time the loop has run a component would be executed. If the file has not changed nothing would happen.

Admittedly not the most elegant way but you could build a small automatic execution machine with this as long as your workflow does run.

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/7/4/74bc376484e6e2cd28db5d42db37f1e15e3b8d63.png)

You can monitor the effect. Every time the trigger file changes the component gets executed. Here there are 10 iterations. At the second iteration the component executes, then nothing happens and then at the iterations 7, 8 and 9 the file has changed and the component executes again (the changes are simulated in the m\_001 workflow - in a real live scenario they would occur by outside factors).

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/c/e/ce49c1ce08fa8d4c5e51ec5bab52ff94ea0d2314.png)

This might serve as an example how such a thing could work. Obviously it would need some work and one can debate if this is the best way to go forward. I would recommend using the **KNIME server** instead 🙂

> **[use the Wait node to execute a database query at fixed times (execution...](https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_db_wait_execute_advanced/m_025_trigger_execution)**
>
> There has been no description set for this workflow's metadata.

(please download the complete workflow group)

This job m\_001 is there to prepare the setting and simulate the changing tigger\_file.csv

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/2/1/211ff1bf905e4addd1a074fd8dcfd1e0717b4b89.png)

You have three components:

- trigger\_file.csv - a simple CSV file that would change over time (a new delivery might be send to a folder)
- trigger\_meta\_list - a small database that would store all the scans of the trigger\_file.csv so you could see if something has changed
- sample\_00 - a dummy database in the same H2 database where you would either do something (if the trigger file is newer= or not

![image](https://forum-cdn.knime.com/uploads/default/original/3X/f/b/fb45d33ecd29130ab78aac45201474c698a9b2d5.png)

> **[use the Wait node to execute a database query at fixed times (preparation...](https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_db_wait_execute_advanced/m_001_trigger_meta_file)**
>
> use the Wait node to execute a database query at fixed times (preparation workflow) 001 - prepare the meta data and simulate changing files Please note: If the…

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 22, 2021, 10:56am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/37 "2021-02-22T10:56:37Z")

</div>

😀 👍 wow - thanks a lot @mlauber71 .  
I´ll trying to follow your workflow.

**About KNIME-Server** :  
 ![Kosten für einen KNIME-Server](https://forum-cdn.knime.com/uploads/default/original/3X/e/2/e28879de0825848a85e95b4d64fe3995e3cd013f.png) 🤔  
In my opinion, an Investment of 12,500 euros for a workflow is  
somewhat disproportionate.

Greetings

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [February 22, 2021, 11:04am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/38 "2021-02-22T11:04:54Z")

</div>

@USCHUKN1ME this very much depends on your business model and what you want to do with it. The KNIME server is much more than one workflow 🙂 - I have a collection about what is possible there:

> **[KNIME - the hub, the server and general praise and remarks – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/latest/_knime_server_hub_general_praise?u=mlauber71)**
>
> KNIME - the hub, the server and general praise and remarks A collection of general remarks and praises about KNIME capabilities, strategy and philosophy as wel…

Also you can use KNIME server with AWS and just pay what you use 🙂  
[https://www.knime.com/knime-software-on-amazon-web-services](https://www.knime.com/knime-software-on-amazon-web-services)

And maybe if you [contact the KNIME team](https://www.knime.com/contact) they might help you with a test license so you can see for yourself …

---

<div class="post-metadata">

**Author:** ![kienerj](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/k/ce7236/32.png) [@kienerj](https://forum.knime.com/u/kienerj)\
**Post date:** [February 23, 2021, 7:13am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/39 "2021-02-23T07:13:55Z")

</div>

> [@USCHUKN1ME](#):
>
> Is it possible to specify **several times**? Loop?

I know I’m very late to the party and maybe given all the replies after this question my reply might not be needed anymore. Still I think it fits to this question. About “times loops” please look at the vernalis community extensions. Yes, they are in the cheminformatics/life science space but also have some general use nodes like timed loops:

![image](https://forum-cdn.knime.com/uploads/default/original/3X/d/b/dba24c3010ca2c5175e0c66baf8b05263f1be478.png)

Maybe these can be helpful for your workflow or workflows in the future.

---

<div class="post-metadata">

**Author:** ![USCHUKN1ME](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uschukn1me/32/54657_2.png) [@USCHUKN1ME](https://forum.knime.com/u/USCHUKN1ME)\
**Post date:** [February 23, 2021, 9:58am UTC](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/40 "2021-02-23T09:58:24Z")

</div>

Hello @kienerj ,

thank you.

You are not too late 🙂

![Chunk Loop Run-to-time Loop Start(A)](https://forum-cdn.knime.com/uploads/default/original/3X/4/9/49259035389244da959870c1032e2935d208a2b2.png)

![Chunk Loop Run-to-time Loop Start(B)](https://forum-cdn.knime.com/uploads/default/original/3X/3/7/374f6cf590351c445763b4858516ce31b47116be.png)

Those are two interesting loop nodes. Which TN take a closer look at.

First, though, l’ll take a closer look at @mlauber71 Suggestion, as it’s  
interesting as well.

Greetings

[Previous page](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287.md?page=1)

[Next page](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287.md?page=3)
