Page 1 of 1

Logrotate domoticz.log on Synology

Posted: Friday 10 February 2017 15:17
by GJKNL
Domoticz is running on a Synology 215j. I use the domoticz logrotate which i found in the "samplescripts" directory which came with the package.:
===
/var/log/domoticz.log {
missingok
weekly
rotate 7
compress
notifempty
postrotate
if [ -x /usr/sbin/invoke-rc.d ]; then \
invoke-rc.d domoticz reload > /dev/null; \
else \
/etc/init.d/domoticz reload > /dev/null; \
fi
endscript
}
===

It creates a file called: domoticz.log.1.xz. There also appears a new domoticz.log, but that file remains empty.

I already searched, but I am a totally noob on this.
Who knows more about this??

Re: Logrotate domoticz.log on Synology

Posted: Saturday 11 February 2017 13:42
by stlaha2007
Initially logging by Domoticz is disabled.
So the logrotate script is useless. However when turning on logging (see domoticz.sh script) you fill the domoticz logfile.

The purpose of logrotate is to prevent extremely large files by 'rotating' logfiles. And becomes handy when something failed and you need to debug.

Re: Logrotate domoticz.log on Synology

Posted: Sunday 12 February 2017 8:50
by GJKNL
Hi,

Logging was active, till logrotate did the job. It seems after that logging stopped. I don't know why

Re: Logrotate domoticz.log on Synology

Posted: Sunday 12 February 2017 9:12
by stlaha2007
Check the /etc/init.d/domoticz.sh for the logging file location. Is it /tmp/ or /var/log/ ?

This script assumes /var/log/. Mine on a pi uses /tmp/.

Re: Logrotate domoticz.log on Synology

Posted: Sunday 12 February 2017 9:41
by GJKNL
On a Synology it is:
/var/packages/domoticz/scripts/start-stop-status

The logging is set to: /var/log/


LOGFILE="/var/log/domoticz.log"

Re: Logrotate domoticz.log on Synology

Posted: Sunday 12 February 2017 11:14
by SweetPants
GJKNL wrote: else \
/etc/init.d/domoticz reload > /dev/null; \
fi
Shouldn't reload be restart?
Usage: /etc/init.d/domoticz {start|stop|status|restart}

Re: Logrotate domoticz.log on Synology

Posted: Sunday 12 February 2017 12:23
by GJKNL
Hmm.. there is no path /etc/init.d

I'm lost now

Re: Logrotate domoticz.log on Synology

Posted: Tuesday 14 February 2017 10:15
by stlaha2007
Perhaps debug whats going on. Eg.:
- Which script start/stop domoticz
- Where is it located
- run it by hand
- check content of that script for logging parameter
- adjust location to logrotate script
- or adjust location in logrotate script to logpath in domoticz start/stop script.

I have Qnap and RPi not Synology. So you need to now first where it is installed, where its start/stop script is located, whats it's content/settings are. Before you just implement an 'out-of-the-box' script.

Re: Logrotate domoticz.log on Synology

Posted: Tuesday 14 February 2017 13:34
by lost
GJKNL wrote: It creates a file called: domoticz.log.1.xz. There also appears a new domoticz.log, but that file remains empty.
Probably because Domoticz always have the file open for writes and does not handle signal sent by logrotate used to tell the process to close current/reopen a new log file.

On my side, for this kind of stuff, I just make a small script that truncate this kind of always open log files to size=0 ("truncate -s 0 LogFileName"). This script is started by a weekly cron job at midnight every monday.

So I always have logs of the week to get good chances to be able to debug a problem & this prevent uncontrolled file size grows.

As the file handle doesn't change with the truncate, this does not disturb further log writes.

Re: Logrotate domoticz.log on Synology

Posted: Thursday 16 February 2017 9:52
by GJKNL
I cannot get logrotate properly working, so I tried truncate as "lost" suggested.
But, when I execute truncate -s 0 on the domoticz logfile, it deletes the content of the file, but the size of the file does not getting smaller. It contains empty space.
I suppose this this is because domoticz is writing continoues into the file?

Re: Logrotate domoticz.log on Synology

Posted: Saturday 18 February 2017 8:51
by lost
GJKNL wrote:I cannot get logrotate properly working, so I tried truncate as "lost" suggested.
But, when I execute truncate -s 0 on the domoticz logfile, it deletes the content of the file, but the size of the file does not getting smaller. It contains empty space.
I suppose this this is because domoticz is writing continoues into the file?
Are you sure to read correctly? On my side, this crontab line works perfectly since 2 month: An empty file means size=0. Otherwise you have a problem (file list size/caching by a file manager? Try ls -al from a terminal).

# m h dom mon dow command
0 0 * * 1 truncate -s 0 /tmp/domoticz.txt

As domoticz log is on a (small) tmpfs in ram not to wear the SD too much, It's run every monday/midnight.

Re: Logrotate domoticz.log on Synology

Posted: Sunday 19 February 2017 8:52
by GJKNL
This is the result after a tructate -s 0 when I do: ls -al in /var/log/

-rw-r--r-- 1 root root 6413863 Feb 19 08:41 domoticz.log

Re: Logrotate domoticz.log on Synology

Posted: Saturday 04 March 2017 5:39
by HansieNL
I couldn't get logrotate properly working too. This is my workaround.

I created file: /home/pi/domoticz/scripts/logrotate/domolog
with content:

/var/tmp/domoticz.log {
missingok
notifempty
size 64k
copytruncate
nocompress
rotate 7
su root root
}


I added a new crontab job: 0 */1 * * sudo logrotate /home/pi/domoticz/scripts/logrotate/domolog


P.s. I did put the file domolog in the logrotate.d map but that didn't work. I hope that someone can tell us what we do wrong so we can correct it.

Re: Logrotate domoticz.log on Synology

Posted: Saturday 04 March 2017 6:32
by Egregius
I just use a scheduled task that runs every Monday morning:
sudo truncate -s 0 /tmp/domoticz.log

Re: Logrotate domoticz.log on Synology

Posted: Saturday 19 August 2017 10:54
by jake
I created the RAM drive and moved the log file according the Wiki. I did the same for the Open Zwave file. Now I see that 'root' is owning both files. Is this correct? I am working on FailToBan and I wonder if FailToBan has access to the log file when 'root' owns it.