# Cron scheduler for jdbc plugin

**URL:** https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878
**Category:** Logstash
**Created:** [February 10, 2021, 1:16pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878 "2021-02-10T13:16:43Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)
#### Post date: [February 10, 2021, 1:16pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/1 "2021-02-10T13:16:44Z")

</div>

Hi,

I am using jdbc plugin and schedule for fetching data from database. Currently cron is running fine for `schedule => "* * * * *"`.  
My requirement is cron ingestion should start at given time (10 pm) and end at given time (12pm) rather than stopping after ingestion is completed.  
Need help in syntax and time format.

Regards,  
Bryce Fernandes.

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [February 10, 2021, 1:25pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/2 "2021-02-10T13:25:02Z")

</div>

How often do you want it to run during the 10pm to 12pm timeframe?

Also here is a [good tool](https://crontab.guru/#*_22,23,0_*_*_*) that helps you with the syntax and gives a plain text explanation on what's going to happen.

---

<div class="post-metadata">

### Author: ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)
#### Post date: [February 10, 2021, 1:37pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/3 "2021-02-10T13:37:16Z")

</div>

Hi @aaron-nimocks

Thanks for the quick reply.  
My use case is such i want to fetch the logs on per day basis. So it doesnt matter how many times it runs in the given time frame. If the data is missed out it would be fetched on the next day.  
So basically i want it to run for the entire time frame so can run either every minute or every 5 minutes.  
How would the syntax be for it ?

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [February 10, 2021, 1:52pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/4 "2021-02-10T13:52:29Z")

</div>

`0 22,23,0 * * *`

That will run at 10:00PM, 11:00PM, and 12:00PM every day. That sounds like it should be plenty for your use case.

---

<div class="post-metadata">

### Author: ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)
#### Post date: [February 10, 2021, 2:06pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/5 "2021-02-10T14:06:25Z")

</div>

Thanks @aaron-nimocks  
Just wanted to know when it starts at 10PM or 11PM or 12PM how long will it run and stop, will it run for a minute and stop?

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [February 10, 2021, 2:15pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/6 "2021-02-10T14:15:01Z")

</div>

It will run until the process is over and start again at the top of the next hour. The schedule looks like below.

10:00PM - Until all records are ingested. No idea how long that takes with your data.  
11:00PM - Until all records are ingested.  
12:00PM - Until all records are ingested.

So it would run 3 times a night which sounds like that is plenty for your use case.

---

<div class="post-metadata">

### Author: ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)
#### Post date: [February 10, 2021, 2:17pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/7 "2021-02-10T14:17:09Z")

</div>

Isnt there a way to stop after 12PM if the data ingestion is not complete but want to stop the cron.

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [February 10, 2021, 2:45pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/8 "2021-02-10T14:45:12Z")

</div>

How long does 1 normal ingestion cycle take?

---

<div class="post-metadata">

### Author: ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)
#### Post date: [February 10, 2021, 2:50pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/9 "2021-02-10T14:50:19Z")

</div>

I am not sure about the data yet have just been given a time frame.  
Also i was testing a sample database with `15-20 20 * * *` and that seems to work.

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [February 10, 2021, 3:01pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/10 "2021-02-10T15:01:55Z")

</div>

That cron will do "At every minute from 15 through 20 past hour 20."

So it will run at the below schedule. If your data takes more than 1 minute to ingest that might not work in the long run and could cause problems.

10:15 PM  
10:16 PM  
10:17 PM  
10:18 PM  
10:19 PM

---

<div class="post-metadata">

### Author: ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)
#### Post date: [February 10, 2021, 3:14pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/11 "2021-02-10T15:14:41Z")

</div>

Thanks @aaron-nimocks  
I guess 3 cycles as you suggested will do the job. Just that had to show some range with stopping point to the management for approval of further testing.  
I guess i can use this with a stopping point.  
`0 21-23 * * *`

Thanks for your quick replies 😃

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 10, 2021, 3:15pm UTC](https://discuss.elastic.co/t/cron-scheduler-for-jdbc-plugin/263878/12 "2021-03-10T15:15:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
