4

I'm having a jdbc connection within my input in logstash where as I'm trying to execute the query according to the schedule property. I went through jdbc and rufus-scheduler, but still pretty unclear of what those five stars(*) represent individually.

As per my knowledge, the stars from left to right (* * * * *):

  1. minute
  2. hour
  3. from (month)
  4. to (month)
  5. day

So if it's a scenario as such (* * * * *), it represents that the scheduler would run every minute. Hence if I'm to run it every five minutes, how the scheduler should look like? Something like (5 * * * *)?

Have I assumed it right? Or correct me if I'm wrong please.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Kulasangar
  • 9,046
  • 5
  • 51
  • 82
  • Adding to @Val's answer, [this](http://www.thegeekstuff.com/2011/07/cron-every-5-minutes/) could be helpful as well. – Kulasangar Nov 16 '16 at 09:54

1 Answers1

15

5 * * * * will run it only once per hour, five minutes after the hour, i.e. at HH:05

If you want to run it every five minutes of every hour, you need to write the schedule like this:

*/5 * * * *
Val
  • 207,596
  • 13
  • 358
  • 360
  • So if I'm using `every` on something, I should be having the slash (/) in front of it? – Kulasangar Nov 16 '16 at 09:10
  • 1
    It depends, but mostly yes. You might want to specify every 15 minutes but only from 10 minutes onwards, you'd then specify like this `10,25,40,55 * * * *` instead of `*/15 * * * *` – Val Nov 16 '16 at 09:14
  • 1
    Every five minutes can also be specified like this `0,5,10,15,20,25,30,35,40,45,50,55 * * * *` but it's longer – Val Nov 16 '16 at 09:15
  • true that. If the minutes are bigger, it's better to go with `10,25,40,55 * * * *` and if the minutes are relatively less, can go with */5 * * * * – Kulasangar Nov 16 '16 at 09:18
  • 1
    No, it has more to do with the starting point, if you start at 0 minutes, then `*/x * * * *` is the way to go, otherwise you need to specify where you start and enumerate each single minute you want to trigger your job. – Val Nov 16 '16 at 09:20
  • Thank you so much. Noted :) – Kulasangar Nov 16 '16 at 09:26