Logrotate domoticz.log on Synology
Moderators: leecollings, remb0
-
- Posts: 38
- Joined: Monday 31 October 2016 9:33
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Logrotate domoticz.log on Synology
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??
===
/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??
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
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.
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.
-
- Posts: 38
- Joined: Monday 31 October 2016 9:33
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
Hi,
Logging was active, till logrotate did the job. It seems after that logging stopped. I don't know why
Logging was active, till logrotate did the job. It seems after that logging stopped. I don't know why
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
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/.
This script assumes /var/log/. Mine on a pi uses /tmp/.
-
- Posts: 38
- Joined: Monday 31 October 2016 9:33
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
On a Synology it is:
/var/packages/domoticz/scripts/start-stop-status
The logging is set to: /var/log/
LOGFILE="/var/log/domoticz.log"
/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
Shouldn't reload be restart?GJKNL wrote: else \
/etc/init.d/domoticz reload > /dev/null; \
fi
Usage: /etc/init.d/domoticz {start|stop|status|restart}
-
- Posts: 38
- Joined: Monday 31 October 2016 9:33
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
Hmm.. there is no path /etc/init.d
I'm lost now
I'm lost now
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
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.
- 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.
-
- Posts: 646
- Joined: Thursday 10 November 2016 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
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.GJKNL wrote: It creates a file called: domoticz.log.1.xz. There also appears a new domoticz.log, but that file remains empty.
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.
-
- Posts: 38
- Joined: Monday 31 October 2016 9:33
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
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?
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?
-
- Posts: 646
- Joined: Thursday 10 November 2016 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
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).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?
# 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.
-
- Posts: 38
- Joined: Monday 31 October 2016 9:33
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
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
-rw-r--r-- 1 root root 6413863 Feb 19 08:41 domoticz.log
- HansieNL
- Posts: 962
- Joined: Monday 28 September 2015 15:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Logrotate domoticz.log on Synology
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.
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.
Last edited by HansieNL on Saturday 04 March 2017 6:39, edited 1 time in total.
Blah blah blah
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Logrotate domoticz.log on Synology
I just use a scheduled task that runs every Monday morning:
sudo truncate -s 0 /tmp/domoticz.log
sudo truncate -s 0 /tmp/domoticz.log
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Logrotate domoticz.log on Synology
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.
Who is online
Users browsing this forum: No registered users and 0 guests