# Logstash JDBC\_INPUT does not push data upon it starts when there's scheduler in its config

**URL:** <https://discuss.elastic.co/t/logstash-jdbc-input-does-not-push-data-upon-it-starts-when-theres-scheduler-in-its-config/372870>\
**Category:** Logstash\
**Created:** [January 6, 2025, 10:55pm UTC](https://discuss.elastic.co/t/logstash-jdbc-input-does-not-push-data-upon-it-starts-when-theres-scheduler-in-its-config/372870 "2025-01-06T22:55:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mxu](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mxu](https://discuss.elastic.co/u/mxu)\
**Post date:** [January 6, 2025, 10:55pm UTC](https://discuss.elastic.co/t/logstash-jdbc-input-does-not-push-data-upon-it-starts-when-theres-scheduler-in-its-config/372870/1 "2025-01-06T22:55:04Z")

</div>

I have following jdbc\_input configured and expect it runs upon logstash starts AND as scheduled as well. However, it did not run upon logstash starts.

I found following old post. It shall run. I have losgtash 8. 13.2.

> [@Does the jdbc\_static loader run once upon logstash start or restart no matter the scheduler?](https://discuss.elastic.co/t/does-the-jdbc-static-loader-run-once-upon-logstash-start-or-restart-no-matter-the-scheduler/246681):
>
> When you start up or restart logstash with a jdbc\_static filter, does the loader automatically run once and then pick up the scheduler? In other words if I have the scheduler set to run once a day at midnight, and I start logstash up at, say, 11:00. Will the loader run then to retrieve the table data and then wait for midnight for the next run.

```auto
jdbc {
    jdbc_driver_library => "xxxxx"
    jdbc_driver_class => "org.postgresql.Driver"
    jdbc_connection_string => "${JDBC_URL}"
    jdbc_user => "${DB_USER}"
    jdbc_password => "${DB_PASSWORD}"
    schedule => "0 4 * * 6"
    statement_filepath => "./config/conf/device_query.sql"
    type => "device"
    jdbc_paging_enabled => true
    jdbc_page_size => "10000"
    jdbc_fetch_size => "10000"
    record_last_run => "false"
  }

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 6, 2025, 11:47pm UTC](https://discuss.elastic.co/t/logstash-jdbc-input-does-not-push-data-upon-it-starts-when-theres-scheduler-in-its-config/372870/2 "2025-01-06T23:47:06Z")

</div>

> [@mxu](#):
>
> I have following jdbc\_input configured and expect it runs upon logstash starts AND as scheduled as well.

That's not how cron works, so it's not how a Rufus cronline works, so it's not how a jdbc input works. If you want both a cron schedule and an invocation at startup then use two inputs.

The behaviour of the jdbc _filters_ is different. They have to be ready to process events once they are initialized, so the have to do the load at startup. Doing a reload based on a schedule is a bonus feature.

---

<div class="post-metadata">

**Author:** ![mxu](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mxu](https://discuss.elastic.co/u/mxu)\
**Post date:** [January 7, 2025, 12:03am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-does-not-push-data-upon-it-starts-when-theres-scheduler-in-its-config/372870/3 "2025-01-07T00:03:18Z")

</div>

Thank you, Badger. My bad, I mixed JDBC\_STATIC filter with JDBC\_INPUT. Now I have following config (two w/ different schedules and one w/o schedule).

```auto
 jdbc {
    jdbc_driver_library => "${DB_JARS}"
    jdbc_driver_class => "org.postgresql.Driver"
    jdbc_connection_string => "${JDBC_URL}"
    jdbc_user => "${DB_USER}"
    jdbc_password => "${DB_PASSWORD}"
    schedule => "${CRON_SCHEDULE}"
    statement_filepath => "./config/conf/sql_incr/device_query.sql"
    type => "device"
    use_column_value => "true"
    tracking_column => "audit_timestamp"
    tracking_column_type => "numeric"
    jdbc_paging_enabled => true
    jdbc_page_size => "10000"
    jdbc_fetch_size => "10000"
    last_run_metadata_path => "${LOGSTASH_TMP_DIR}/.logstash_jdbc_last_run_ts_device"
  }

  # Full push: Run once on start-up and as scheduled
  jdbc {
    jdbc_driver_library => "${DB_JARS}"
    jdbc_driver_class => "org.postgresql.Driver"
    jdbc_connection_string => "${JDBC_URL}"
    jdbc_user => "${DB_USER}"
    jdbc_password => "${DB_PASSWORD}"
    statement_filepath => "./config/conf/${SQL_FULL_PATH}/device_query.sql"
    type => "device"
    jdbc_paging_enabled => true
    jdbc_page_size => "10000"
    jdbc_fetch_size => "10000"
    record_last_run => "false"
  }
  jdbc {
    jdbc_driver_library => "${DB_JARS}"
    jdbc_driver_class => "org.postgresql.Driver"
    jdbc_connection_string => "${JDBC_URL}"
    jdbc_user => "${DB_USER}"
    jdbc_password => "${DB_PASSWORD}"
    schedule => "${FULL_SYNC_CRON_SCHEDULE}"
    statement_filepath => "./config/conf/${SQL_FULL_PATH}/device_query.sql"
    type => "device"
    jdbc_paging_enabled => true
    jdbc_page_size => "10000"
    jdbc_fetch_size => "10000"
    record_last_run => "false"
  }

```
