From a4ece0fe3f4c6e6dcfff903c52617f1392e193a9 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 16 Jan 2018 17:39:16 +0100 Subject: [PATCH] Add log rotate, log, condition and non-SIGHUP example .conf sample Signed-off-by: Joachim Nilsson --- README.md | 11 +++++++++++ contrib/finit.conf | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index cd8674c5..dd83ba01 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,23 @@ host default # Runlevel to start after bootstrap, 'S', default: 2 runlevel 2 +# Max file size for each log file: 100 kiB, rotate max 4 copies: +# log => log.1 => log.2.gz => log.3.gz => log.4.gz +log size=100k count=4 + # Services to be monitored and respawned as needed service [S12345] /sbin/watchdogd -L -f -- System watchdog daemon service [S12345] /sbin/syslogd -n -b 3 -D -- System log daemon service [S12345] /sbin/klogd -n -- Kernel log daemon service [2345] /sbin/lldpd -d -c -M1 -H0 -i -- LLDP daemon (IEEE 802.1ab) +# The BusyBox ntpd does not use syslog when running in the foreground +# So we use this trick to redirect stdout/stderr to a log file. The +# log file is rotated with the above settings. The condition declares +# a dependency on a system default route (gateway) to be set. A single +# at the beginning means ntpd does not respect SIGHUP for restart. +service [2345] log:/var/log/ntpd.log /sbin/ntpd -n -l -I eth0 -- NTP daemon + # For multiple instances of the same service, add :ID somewhere between # the service/run/task keyword and the command. service :1 [2345] /sbin/merecat -n -p 80 /var/www -- Web server diff --git a/contrib/finit.conf b/contrib/finit.conf index 8b91ae13..a8facfa5 100644 --- a/contrib/finit.conf +++ b/contrib/finit.conf @@ -17,6 +17,10 @@ runlevel 2 # Network bringup script network service networking start +# Max file size for each log file: 100 kiB, rotate max 4 copies: +# log => log.1 => log.2.gz => log.3.gz => log.4.gz +log size=100k count=4 + # Virtual consoles to start getty on tty /dev/tty1 tty /dev/tty2 @@ -33,6 +37,13 @@ service [2345] /sbin/klogd -n -- Kernel logging server service [2345] /sbin/syslogd -n -- Syslog server service [3] /usr/sbin/gdm -- GNOME Display Manager +# The BusyBox ntpd does not use syslog when running in the foreground +# So we use this trick to redirect stdout/stderr to a log file. The +# log file is rotated with the above settings. The condition declares +# a dependency on a system default route (gateway) to be set. A single +# at the beginning means ntpd does not respect SIGHUP for restart. +service [2345] log:/var/log/ntpd.log /sbin/ntpd -n -l -I eth0 -- NTP daemon + # Run start scripts from this directory # runparts /etc/start.d