Restart openhab every day

I have my openhab running with a raspberrypi2 which works fine for a couple of days, then I get java heap space curse every 3 days. I could not get the reason why the java heap space is triggered and to fix this I want to be able to restart my openhab every day with cron.
I add a line to my cron like this:

//Added this line to restart every day at 03AM
0 3 * * * root /etc/init.d/openhab restart 

Cron tries to restart it because if I do “tail -f /var/log/syslog” I get this:

Nov  4 02:01:12 raspberrypi crontab[4068]: (root) END EDIT (root)
Nov  4 02:01:01 raspberrypi /usr/sbin/cron[1972]: (root) RELOAD (crontabs/root)
Nov  4 03:01:01 raspberrypi /USR/SBIN/CRON[4100]: (root) CMD (root /etc/init.d/openhab restart)
Nov  4 03:01:01 raspberrypi /USR/SBIN/CRON[4099]: (CRON) info (No MTA installed, discarding output)

Openhab is not restarted, if I try to run /etc/init.d/openhab restart with root it restarts.I know this because the time gap in events.log under openhab/logs

Any idea how can I achieve this

In my side I’m doing my cron job like this:
0 5 * * * sudo mysqldump …

maybe you could try like this:
0 3 * * * sudo /etc/init.d/openhab restart

Appart from that your openhab is not installed as a service? If it is the case you can do:
0 3 * * * sudo service openhab restart

Adding the sudo fix my problem.It is now restarting the service just fine.This is just a fast fix for java heap space curse, since this is ghosting me a while.
Thanks for your time dude.
Happy openhabing :slight_smile:

Glad to hear, have a good night

Just wanted to add: Having to restart openHAB is not how it should normally be. If you or anybody else having the need to restart openHAB from time to time think the problem you are having might be a bug in openHAB, PLEASE file a bug report to help fix this problem for you and others. :wink:

I would like to help fix this, like I said this is just a fast fix.I could’t discover the cause of the java heap space after some test unfortunately.(I tried to remove some bindings and let the system run, try to debug with top linux command ) but after 3 days java heap space curse.Somehow something is not releasing the allocated memory causing it to go up and up I believe.
what log should I share to be useful to track the cause?
event.log and openhab.log?

I think the only thing that would help is to identify the binding/addon that is causing it. The core runtime does not have any memory problems, this is running in many installations under heavy load for months without problems.