# Possible to specify start and end time as part of schedule?

**URL:** https://discuss.elastic.co/t/possible-to-specify-start-and-end-time-as-part-of-schedule/126747
**Category:** Logstash
**Created:** [April 4, 2018, 1:45pm UTC](https://discuss.elastic.co/t/possible-to-specify-start-and-end-time-as-part-of-schedule/126747 "2018-04-04T13:45:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ParitoshBh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paritoshbh/32/22487_2.png) [@ParitoshBh](https://discuss.elastic.co/u/ParitoshBh)
#### Post date: [April 4, 2018, 1:45pm UTC](https://discuss.elastic.co/t/possible-to-specify-start-and-end-time-as-part-of-schedule/126747/1 "2018-04-04T13:45:34Z")

</div>

I am trying to schedule a job that runs every 5 minutes starting at 1 a.m. and ending at 11 p.m. Here's the expression I am planning to use,

`0 0/5 1-23 ? * * *`

I have minimal knowledge in cron but based on the [JDBC input plugin documentation](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_scheduling_2) it uses rufus scheduler whereas the syntax above is more suited towards quartz.

I do understand _quartz != cron_ but what's not clear is would the expression be acceptable for logstash. If not, is there a way to achieve the same behavior with rufus scheduler?

Edit: The expression above doesn't work, logstash throws following error (in log files),

```auto
Input plugin raised exception during shutdown, ignoring it. {:plugin=>"jdbc", 
:exception=>"not a valid cronline : '0 0/5 1-23 ? * * *'", :backtrace=>[
"/usr/share/logstash/vendor/bundle/jruby/1.9/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/cronline.rb:61:in 
`initialize'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:604:in 
`initialize'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler.rb:629:in 
`do_schedule'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler.rb:244:in 
`cron'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-jdbc-4.3.1/lib/logstash/inputs/jdbc.rb:249:in 
`run'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:470:in 
`inputworker'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:463:in `start_input'"]}

```

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [April 4, 2018, 2:22pm UTC](https://discuss.elastic.co/t/possible-to-specify-start-and-end-time-as-part-of-schedule/126747/2 "2018-04-04T14:22:55Z")

</div>

Aren't you just specifying too many fields? A cron line has five columns, not seven. For starters, shouldn't you remove the leading zero?

---

<div class="post-metadata">

### Author: ![ParitoshBh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paritoshbh/32/22487_2.png) [@ParitoshBh](https://discuss.elastic.co/u/ParitoshBh)
#### Post date: [April 4, 2018, 2:33pm UTC](https://discuss.elastic.co/t/possible-to-specify-start-and-end-time-as-part-of-schedule/126747/3 "2018-04-04T14:33:54Z")

</div>

> Aren't you just specifying too many fields? A cron line has five columns, not seven. For starters, shouldn't you remove the leading zero?

The syntax is more suited towards use with quartz. My reference point and [more on that](http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html)

Quickly checked [here](https://www.freeformatter.com/cron-expression-generator-quartz.html#crongenerator) and it appears to a be a valid syntax (for Quartz) with explanation as follows,

> At second :00, every 5 minutes starting at minute :00, every hour between 01am and 23pm, of every day

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [April 5, 2018, 6:28am UTC](https://discuss.elastic.co/t/possible-to-specify-start-and-end-time-as-part-of-schedule/126747/4 "2018-04-05T06:28:07Z")

</div>

As I said, drop the initial zero since the cron syntax supported by jdbc doesn't support seconds, then drop the last `*` that represents the year since jdbc doesn't support that either. The `?` marker doesn't work either.

---

<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: [May 3, 2018, 6:28am UTC](https://discuss.elastic.co/t/possible-to-specify-start-and-end-time-as-part-of-schedule/126747/5 "2018-05-03T06:28:09Z")

</div>

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