# Logstash cron schedule to run every 12 hours starting at certain time

**URL:** <https://discuss.elastic.co/t/logstash-cron-schedule-to-run-every-12-hours-starting-at-certain-time/142356>\
**Category:** Logstash\
**Created:** [July 31, 2018, 11:58am UTC](https://discuss.elastic.co/t/logstash-cron-schedule-to-run-every-12-hours-starting-at-certain-time/142356 "2018-07-31T11:58:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhisheksimion](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhisheksimion/32/24623_2.png) [@abhisheksimion](https://discuss.elastic.co/u/abhisheksimion)\
**Post date:** [July 31, 2018, 11:58am UTC](https://discuss.elastic.co/t/logstash-cron-schedule-to-run-every-12-hours-starting-at-certain-time/142356/1 "2018-07-31T11:58:51Z")

</div>

I am trying `0 1/12 * * *` cron expression but it only fires once a day. Below is 1 of my configuration.

```
input {
	jdbc {
		jdbc_connection_string => "jdbc:redshift://xxx.us-west-2.redshift.amazonaws.com:5439/xxx"
		jdbc_user => "xxx"
		jdbc_password => "xxx"
		jdbc_validate_connection => true
		jdbc_driver_library => "/mnt/logstash-6.0.0/RedshiftJDBC42-1.2.10.1009.jar"
		jdbc_driver_class => "com.amazon.redshift.jdbc42.Driver"
		schedule => "0 1/12 * * *" #01:00,13:00, tried from https://crontab.guru/#0_1/12_*_*_*
		statement_filepath => "conf/log_event_query.sql"
		use_column_value => true
		tracking_column => dw_insert_dt
		last_run_metadata_path => "metadata/logstash_jdbc_last_run_log_event"
	}
}
output {
	elasticsearch {
		index => "logs-ics_%{+dd_MM_YYYY}"
		document_type => "log_event"
		document_id => "%{log_entry_id}"
		hosts => ["10.137.6.182:17002"]
	}
}

```

I also tried below `0 0 1/12 ? * * *` from [https://www.freeformatter.com/cron-expression-generator-quartz.html](https://www.freeformatter.com/cron-expression-generator-quartz.html) but lostash does not support this type.  
[Original](https://crontab.guru/#0_1/12_*_*_*) cron used. Please help me get a cron expression which works in logstash. according to following dates and also is there a online page where I can test my future logstash cron expressions?

```
1st at 2018-08-01 01:00:00
then at 2018-08-01 13:00:00
then at 2018-08-02 01:00:00
then at 2018-08-02 13:00:00
then at 2018-08-03 01:00:00
```

---

<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:** [July 31, 2018, 12:04pm UTC](https://discuss.elastic.co/t/logstash-cron-schedule-to-run-every-12-hours-starting-at-certain-time/142356/2 "2018-07-31T12:04:04Z")

</div>

Off the top of my head, I would expect you to need \*/12, not 1/12. I haven't tested it though.

---

<div class="post-metadata">

**Author:** ![abhisheksimion](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhisheksimion/32/24623_2.png) [@abhisheksimion](https://discuss.elastic.co/u/abhisheksimion)\
**Post date:** [July 31, 2018, 12:11pm UTC](https://discuss.elastic.co/t/logstash-cron-schedule-to-run-every-12-hours-starting-at-certain-time/142356/3 "2018-07-31T12:11:18Z")

</div>

@Badger Thanks for your reply. Also what if I want to start my 12 hour schedule at 2am? Will this solution work?

---

<div class="post-metadata">

**Author:** ![tgaudin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tgaudin/32/32583_2.png) [@tgaudin](https://discuss.elastic.co/u/tgaudin)\
**Post date:** [July 31, 2018, 12:16pm UTC](https://discuss.elastic.co/t/logstash-cron-schedule-to-run-every-12-hours-starting-at-certain-time/142356/4 "2018-07-31T12:16:31Z")

</div>

Why not `0 1,13 * * *`? [crontab.guru](https://crontab.guru/#0_1,13_*_*_*)

---

<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:** [August 28, 2018, 12:16pm UTC](https://discuss.elastic.co/t/logstash-cron-schedule-to-run-every-12-hours-starting-at-certain-time/142356/5 "2018-08-28T12:16:35Z")

</div>

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