
Platform information:
 Hardware: pi3+
 OS: raspbian stretch
 Java Runtime Environment: java
 openHAB version: 2

Issue of the topic:
When I update my rule with a cron job statement in it somtimes it started the cronjob somtimes i need to restart openhab2 completely??? Why? how can I force to start the cron job??
Problems using Cron in a rule
“forcing” a cron job to start is nonsensical.
Please read the tutorial on how to ask for help.
My finding so far…
evrything is running fine but if i do this calculation in my rule it stopps
var String local_string_yesterday = now.minusDays(1).toString("yyyyMMdd") + "T23:59:00.0000"
var Number local_number_wallplug2dailytotalenergy = (Z_way_number_WallPlug2_totalpower.state as DecimalType)  (Z_way_number_WallPlug2_totalpower.historicState(parse(local_string_yesterday)).state as DecimalType)
any Idea ???
Change to:
var DateTime local_time_yesterday = new DateTimeType(now.withTimeAtStartOfDay.minusMinutes(1).toString)
var Number local_number_wallplug2dailytotalenergy = (Z_way_number_WallPlug2_totalpower.state as Number)  (Z_way_number_WallPlug2_totalpower.historicState(local_time_yesterday)).state as Number)
Please post you item definitions, if you are using the UoM this will not work and you need another approach
Item
Number Z_way_number_WallPlug2_totalpower "Wallplug2 [%.3f]" (group_house_totalenergy) {channel="zway:zwayDevice:e5c7e372:2:sensorMultilevelZWayVDev_zway_20500"}
your version had an error:
Error during the execution of rule 'dailytotalenergy': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.persistence.extensions.PersistenceExtensions.historicState(org.eclipse.smarthome.core.items.Item,org.joda.time.base.AbstractInstant) on instance: null
Try this:
var local_time_yesterday = now.withTimeAtStartOfDay.minusMinutes(1)
var Number local_number_wallplug2dailytotalenergy = (Z_way_number_WallPlug2_totalpower.state as Number)  (Z_way_number_WallPlug2_totalpower.historicState(local_time_yesterday)).state as Number)
Still the same issue if iI run 1 calculation like this everything is fine but if I run 3 of them it stopped after a certain time
rule "dailytotalenergy"
when
Time cron "0 0/1 * * * ?"
then
var local_time_yesterday = now.withTimeAtStartOfDay.minusMinutes(1)
var Number local_number_wallplug2dailytotalenergy = (Z_way_number_WallPlug2_totalpower.state as Number)  (Z_way_number_WallPlug2_totalpower.historicState(local_time_yesterday).state as Number)
var Number local_number_wallplug3dailytotalenergy = (Z_way_number_WallPlug3_totalpower.state as Number)  (Z_way_number_WallPlug3_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug4dailytotalenergy = (Z_way_number_WallPlug4_totalpower.state as Number)  (Z_way_number_WallPlug4_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug5dailytotalenergy = (Z_way_number_WallPlug5_totalpower.state as Number)  (Z_way_number_WallPlug5_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug6dailytotalenergy = (Z_way_number_WallPlug6_totalpower.state as Number)  (Z_way_number_WallPlug6_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug7dailytotalenergy = (Z_way_number_WallPlug7_totalpower.state as Number)  (Z_way_number_WallPlug7_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug8dailytotalenergy = (Z_way_number_WallPlug8_totalpower.state as Number)  (Z_way_number_WallPlug8_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug9dailytotalenergy = (Z_way_number_WallPlug9_totalpower.state as Number)  (Z_way_number_WallPlug9_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug10dailytotalenergy = (Z_way_number_WallPlug10_totalpower.state as Number)  (Z_way_number_WallPlug10_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug11dailytotalenergy = (Z_way_number_WallPlug11_totalpower.state as Number)  (Z_way_number_WallPlug11_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug12dailytotalenergy = (Z_way_number_WallPlug12_totalpower.state as Number)  (Z_way_number_WallPlug12_totalpower.historicState(local_time_yesterday).state as Number)
//var Number local_number_wallplug13dailytotalenergy = (Z_way_number_WallPlug13_totalpower.state as Number)  (Z_way_number_WallPlug13_totalpower.historicState(local_time_yesterday).state as Number)
var Number local_number_dailytotalenergy = local_number_wallplug2dailytotalenergy + local_number_wallplug3dailytotalenergy
number_dailytotalenergy.postUpdate(local_number_dailytotalenergy)
logInfo("yesterday is", local_time_yesterday.toString())
end
Maybe this item is wrong???
Number HTTP_number_pm10 "PM10: [%s µg/m³]" { http="<[http_luftdaten_2730:60000:JSONPATH($[0].sensordatavalues[0].value)]"}
Number HTTP_number_pm2_5 "PM2,5: [%s µg/m³]" { http="<[http_luftdaten_2730:60000:JSONPATH($[0].sensordatavalues[1].value)]"}
Why are you running this rule every minute?
Replace your cron with "0 0/1 * ? * * *"
Due to testing how it works…later I want to do it if sth. changed…
I came from an other system and there it works…
I found out that I had 32000 mysql connections after 6h running openhab without it was round 4.
MariaDB [(none)]> show status like 'Conn%';
+++
 Variable_name  Value 
+++
 Connection_errors_accept  0 
 Connection_errors_internal  0 
 Connection_errors_max_connections  0 
 Connection_errors_peer_address  0 
 Connection_errors_select  0 
 Connection_errors_tcpwrap  0 
 Connections  123 
+++
7 rows in set (0.00 sec)
After round 30min I have 123 connections…but only running mysql.persist
// persistence strategies have a name and a definition and are referred to in t$
Strategies {
everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
default = everyChange
}
Items {
MQTT_number_weewx_outHumidity : strategy = everyMinute, restoreOnStartup
group_test* : strategy = everyMinute, restoreOnStartup
group_house_totalenergy* : strategy = everyMinute, restoreOnStartup
group_house_actualpower* : strategy = everyMinute, restoreOnStartup
}