HA auto restarts every morning

is the pi on a smart switch?

I am not really sure what you mean on a smart switch (something to turn it on and off?), but if thats the case, then no. If you read my first post:

So… the pi doesnt lose its power.

crontab? There has to be a reason and not necessarily home assistant…

Anything else?

for the sudo user as well as any other users?

Yes, it looks like it.

Is there a way to list cron jobs for all users in case I missed any? Even though I am pretty sure I checked everything ( I just rechecked to be sure), but you never know.

If you are absolutely sure that nothing in your config or automations are causing the reboot, one last thing I would suggest (and it sucks) is to take a snapshot of your current config, and rebuild your pi…but since you say its at precise 6:25am, then I would thing that there is a job running somewhere that you have forgotten about. Nothing about 6:25 rings a bell for you?

1 Like

Absolutely nothing. At weekdays, I have my phone alarm for work at 06:25 and I even thought it might be an issue (stupid, but could be - I have seen everything in my life) so I changed the time 5 minutes later today - still the same thing.

I cant be absolutely sure about anything. All I can say is “I think” I have checked everything. Thats why I posted here. You guys can help me figure it out.
Nobody knows a way to keep track of the log BEFORE restarting HA? :confused:
Too bad.

You could create a cronjob to copy to log file to another directory at 6:24am.

Is the operating system restarting too, or is it just HA

@Mirai_Hayashi It is just HA. The OS is running without interruptions.
@kanga_who That is actually a great idea!
But HA is not writing the log in a file, unless it cannot start (due to invalid config).
Unless I am missing something.

Experiment with 6:24:58am, see if it catches something happening just before 6:25:00. That’s my only suggestion.

It seems like you have an automation causes the restart, or a cronjob that you can’t find, though.

My point is, what can you copy if there is nothing to copy? Can you see your log file now? Is there anything written to that file? Mine has the last time I stopped HA, changed the config and tried to start again, but the config was invalid. That was 10 days ago…

I agree with kanga…If its a system fault, I doubt that it would restart precisely at the same time everyday. There is a scheduled job or automation somewhere…maybe the job is not on HA but on some external system that has access to your server. Are you exposing your HA to the internet in any way?

Yes, the HA is log normally located in /home/homeassistant or /home/homeassistant/.homeassistant if in a venv.

It’s in the same place as where all your config files are located and is called home-assistant.log

@Mirai_Hayashi That is something I completely agree with you. I am just trying to find out what it is. Yes I have my HA exposed, but only to my mobile. I will disable access tonight and will see tomorrow what will happen.

@kanga_who I know… The file is there for me too, but its contents is 10 days ago where I had a misconfiguration. I mean, the log is stored in the database, right? IF and I capitalize IF again, you stop HA, change your config to an invalid configuration and try to start HA, ONLY THEN it will write the log file, so you can see what error came up, because you cant see it in the frontend since HA is down.

Every time there is an warning, error, an unreachable entity, etc. HA will log it to that file.

If it is not logging to that file location, I think your config is in a different folder, potentially, and therefore so is your log file. My log file updates every time an event occurs.

Thanks for the heads up! My log is located at /var/log/homeassistant

Cronjob here I come!

1 Like

Please bare with me. I have already spammed this thread a lot. I know…

Since I found my log file, I realized I dont have to cronjob it, since it already kept a copy of itself!
I created a samba share for convenience and here is what I see:

Capture

Notice the time on the home-assistant.log.1 —> 06:25 Yay!!
In fact every log back up is at the same time…
Opening the logs, I am seeing this as the last log written in every file:

2019-01-28 06:25:04 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.1609406352] Connection closed by client
2019-01-28 06:25:05 INFO (Thread-20) [pywemo.subscribe] Terminated threads

This is not helpful to me… How about you guys?

EDIT:
Now… Something else came to my mind… Might be stupid, but I have to ask to exclude it from my list:
Is there a chance HA is splitting/backing up the logs and marks this behavior as a Restart?

Thank you guys for all the help. You really helped me to figure out what is going on by eliminating things.
I found what the problem is:

CREATE LOGROTATE RULE
This logrotate script at /etc/logrotate.d/homeassistant will create an outage of a few seconds every week at night. If you do not want this add --log-rotate-days 7 to the FLAGS variable in the init script.

See… I knew it had to be something stupid and there it is.