autorestart

Forum for questions and support relating to the 1.30.x releases only.
Locked
davic
Posts: 17
Joined: Thu May 20, 2010 9:41 am

autorestart

Post by davic »

hi, ZM stops about once a day (tipically at night) and I'm not able to understand why.
How can I get autorestart?
thanks
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: autorestart

Post by knight-of-ni »

You didn't tell us what distro you are running, but it's probably safe to assume your distro is using systemd.

1) Make a copy of your zoneminder.service file and place it into /etc/systemd/system.
This file is typically under /lib/systemd/system for debian & ubuntu and /usr/lib/systemd/system for redhat.
It is important you don't modify the original service file as that will get overwritten during an upgrade.

2) Add the line "restart=always" under the [service] block.

3) Issue a "sudo systemctl daemon-reload && sudo systemctl restart zoneminder" and you are done.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
davic
Posts: 17
Joined: Thu May 20, 2010 9:41 am

Re: autorestart

Post by davic »

thanks very much.
My distro is ubuntu 16.04 server.
I suggest to insert this in the wiki.
thanks again
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: autorestart

Post by knight-of-ni »

I personally wouldn't add it to the wiki because it doesn't address the real problem of why the service is stopped in the first place.
However, our wiki is community based. Anyone can add content to it, and you are welcome to add this yourself. I certainly won't object.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
iconnor
Posts: 2900
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: autorestart

Post by iconnor »

mysql gets restarted for log rotation. This kills zoneminder.

edit

/etc/systemd/system/multi-user.target.wants/zoneminder.service

And change the line with Restart=something
to Restart=always
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: autorestart

Post by knight-of-ni »

iconnor wrote: Sun Mar 04, 2018 7:44 pm mysql gets restarted for log rotation. This kills zoneminder.

edit

/etc/systemd/system/multi-user.target.wants/zoneminder.service

And change the line with Restart=something
to Restart=always
Mysql doesn't restart on logrotate on any of the machines I'm running. Just to be sure, I did just check three of them. In addition, If I manually restart mysql, systemd automatically restarts zoneminder as well. ZoneMinder is not left in a stopped state, and I don't have restart=always in my zoneminder service file. It would be interesting to know exactly what cases you've seen this occurring so we can narrow it down to a specific set of conditions that might cause this problem.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
Viher
Posts: 20
Joined: Fri May 05, 2017 7:09 am

Re: autorestart

Post by Viher »

Zoneminder stopping without obvious reason happens here too, and has been happening since I started using Zoneminder (1.28 then 1.30 now) I used to make a cronjob that checked if the ZM was runninng and restarting it if not. Happens once per day, time of day isn't same. I'm using Ubuntu Server 16.04.4 LTS 4.4.0-116.

Thank you knnnigget for the systemd guide.
Last edited by Viher on Thu Mar 15, 2018 9:02 am, edited 1 time in total.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: autorestart

Post by knight-of-ni »

The next time it happens, check your mysql/mariadb logs during the same timeframe to see if your database restarted.
I don't doubt iconnor has seen this happen, but I'm not able to duplicate it. It would be extremely helpful if we could narrow down under what conditions this occurs.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
davic
Posts: 17
Joined: Thu May 20, 2010 9:41 am

Re: autorestart

Post by davic »

I think something went wrong with log. Zoneminder never stopped but today mysql and ubuntu was not able to work because no space on HD. I found 99% of used space. After analysing all big files I found in /var/log/zm a lot of "zm_debug_log.****" file for about 220 GB.
Locked