SQlite persistence triggering every 1 minutes works, but every 5 minutes fails


(Tobias) #1

Dear all,

I implemented a persistence simply writing some values on change and others every 1 minute. So this works:

// Persistence Strategien haben einen Namen und eine Definition
Strategies {
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"
    every5Minutes  : "0 0/1 * * * ?"                      
    // Wenn bei einem unten definierten Item keine Strategie angebeben ist,
    // wird die Default-Liste angewendet
    default = everyChange
}

Items {
    Night_Light_Brightness_Tobias : strategy = everyChange
    Heating_LivingRoom, Heating_Kitchen : strategy = every5Minutes
}

and it writes periodic date at e.g. 21:00h, 21:01h, 21:02h… (21:00h was just an example, it records this way around the clock…)
BUT
Setting the cron job to two minutes to get data at e.g. 21:00h, 21:02h, 21:04h…

...    
every5Minutes  : "0 0/2 * * * ?"                      
...

or at 21:00h, 21:05h, 21:015h…

...    
every5Minutes  : "0 0/5 * * * ?"                      
...

fails and the persistence stops to write the periodic data.

What do I do wrong?

Thanks for help!


(Matthias) #2

Hi,

are you sure about the service you are using? Sounds like a rrd4j issue:

" IMPORTANT

The strategy everyMinute (60 seconds) MUST be used, otherwise no data will be persisted (stored). Other strategies can be used too."


(Tobias) #3

Hmm, I definitely use SQlite:

# D A T A B A S E  C O N F I G
# Some URL-Examples, 'service' identifies and activates internally the correct jdbc driver.
# required database url like 'jdbc:<service>:<host>[:<port>;<attributes>]'
# url=jdbc:derby:./testDerby;create=true
# url=jdbc:h2:./testH2
# url=jdbc:hsqldb:./testHsqlDb
# url=jdbc:mariadb://192.168.0.1:3306/testMariadb
# url=jdbc:mysql://192.168.0.1:3306/testMysql
# url=jdbc:postgresql://192.168.0.1:5432/testPostgresql
url=jdbc:sqlite:sqlite/testSqlite.db
# url=

Basically, this SQlite file is indeed storing the data (with the one minute rule), so the service itself is running well…


(Angelos) #4

try:

every5Minutes : 0 */5 * ? * *	

OH2 uses a quartz scheduler. Validation for cron expressions using quartz here: https://www.freeformatter.com/cron-expression-generator-quartz.html


(Tobias) #5

Ok, that seems to work, but the service only starts after the next full hour… is this possible? I’ll let it run tonight.
Btw.: That web page is really useful - thanks :slight_smile: