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

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 but lostash does not support this type.
Original 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

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

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

Why not 0 1,13 * * *? crontab.guru

1 Like

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