Date: Wed, 15 Dec 2010 15:42:29 +0100 From: =?ISO-8859-1?Q?Samuel_Mart=EDn_Moro?= <faust64@gmail.com> To: Ian Smith <smithi@nimnet.asn.au> Cc: freebsd-questions@freebsd.org Subject: Re: boot, rc script and logs Message-ID: <AANLkTinRDa89gH5jXMeDkTbdu9yrLGcNev7YK15dUauw@mail.gmail.com> In-Reply-To: <20101215140116.M83735@sola.nimnet.asn.au> References: <20101214180343.F008310656F6@hub.freebsd.org> <20101215140116.M83735@sola.nimnet.asn.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Dec 15, 2010 at 4:57 AM, Ian Smith <smithi@nimnet.asn.au> wrote: > In freebsd-questions Digest, Vol 341, Issue 3, Message: 17 > On Tue, 14 Dec 2010 19:02:54 +0100 Samuel Mart?n Moro <faust64@gmail.com> > wrote: > > Hi, > > > > I'm adding some scripts to FreeBSD boot. > > One of this script runs a binary that checks our postgres database, it= s > > output being redirected to a dialog --gauge. > > But I noticed that the dialog output, while correctly displayed on the > > terminal, is also dumped into /var/log/console.log and > /var/log/messages. > > > > I'm not even sure about how this is happening... I can't find about > messages > > nor console.log in /etc/rc* > > As you indicate below, 'tty is /dev/console' while running the boot rc > scripts, so it's normal to see these scripts logged to console.log when > that's ebabled .. presumably /etc/syslog.conf includes something like: > # uncomment this to log all writes to /dev/console to /var/log/console.lo= g > console.info /var/log/console.log > indeed it does. > > > Is there a way to disable log output in a given rc.script? > > > > here's my script: > > #!/bin/sh > > [...] > > test "$1" =3D 'start' -o "$1" =3D 'faststart' || exit 0 > > Prg=3D`basename $_file` > > exec 2>/var/log/$Prg.log > > You're redirecting stderr to your logfile, but not stdout, so standard > output from the below goes to /dev/console, so also to /console.log > > > test "$TERM" || export TERM=3Dcons25 > > DIALOG=3D"/usr/local/bin/dialog --no-collapse --cr-wrap --colo= rs" > > echo "tty is `tty`" >&2 #debug, prints: tty is /dev/console > > echo "=3D=3D=3D=3D=3D Checking DB 1/2 =3D=3D=3D=3D=3D" >&2 > > The above line is also written to stdout, so to console.log below, so > I'm not sure whether your exec usage | syntax | redirection is correct. > it is dialog is used to display menus using curses during the boot process, everything "looks" fine (except for logs), menus are correctly displayed, while processing the DB scan. > > > dbcheck -s | $DIALOG --gauge "\n Checking DB 1/2" 7 70 > 2>/dev/null > > echo "=3D=3D=3D=3D=3D Checking DB 2/2 =3D=3D=3D=3D=3D" >&2 > > dbcheck -r -s | $DIALOG --gauge "\n Checking DB 2/2" 7 70 > 2>/dev/null > > [...] > > > > here is what it gives in /var/log/messages: > > Dec 14 13:26:46 camtrace13 dhclient: New Subnet Mask (wlan0): > 255.255.255.0 > > Dec 14 13:26:46 camtrace13 dhclient: New Broadcast Address (wlan0): > > 192.168.0.255 > > Dec 14 13:26:46 camtrace13 dhclient: New Routers (wlan0): 192.33.160.1= 11 > > Dec 14 13:26:47 camtrace13 kernel: m ^[[36m^[[44m^[[K^[[16;6H^[[1K > > ^[[30m^[[40m^[[70X^[[77`^[[36m^[[44m^[[K^[[13;9H^[[39;49m^[[m > > Dec 14 13:26:48 camtrace13 kernel: m ^[[36m^[[44m^[[K^[[16;6H^[[1K > > ^[[30m^[[40m^[[70X^[[77`^[[36m^[[44m^[[K^[[13;9H^[[39;49m^[[m > > I don't know why those two dialog lines are sent to /var/log/messages; > perhaps they indicate some error, only those being logged with *.notice? > this lines are mostly color code, used to display a grey window with a gauge, on a blue background. > > [..] > > > and here is what I can read in /var/log/console.log: > > Dec 14 13:26:43 camtrace13 kernel: Starting apache. > > Dec 14 13:26:46 camtrace13 kernel: Starting pgsql. > > If you view these scripts you'll see that they don't themselves write to > stdout .. it's the rc system logging these. > indeed, I noticed yesterday that "Starting ${name}" is part of rc.subr > > > Dec 14 13:26:47 camtrace13 kernel: ^[[m > > Dec 14 13:26:47 camtrace13 kernel: ^[[39;49m^[[=3D1S > > Dec 14 13:26:47 camtrace13 kernel: > > > ^[[39;49m^[[m^[[H^[[J^[[17d^[[36m^[[44m^[[1m^[[J^[[H^[[K^[[B^[[K^[[B^[[K^= [[B^[[K^[[B^[[K^[[B^[[K^[[B^[[K^[[B^[[K^[[B > * > ^[[37m^[[**47m=E8=B0=80=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA= =E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5= =93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93= =AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA** > =E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E5=93=AA=E8=85=B2[= [m^[[30m^[[47m=E7=B8=99[[m^[[**36m^[[44m^[[1m^[[K^[[B* > err.. we may have a encoding problem. but I'm quite sure it only is clearscreen, colors, and tputs stuff > > ^[[37m^[[47m=E7=A0=A0[[m^[[30m^[[47m^[[68X^[[74`=E7=A0=A0[[m^[[30m^[[4= 0m^[[1m > > ^[[36m^[[44m^[[K^[[B ^[[37m^[[47m=E7=A0=A0[[m^[[30m^[[47m Checkin= g DB > > 1/2^[[20X^[[74`=E7=A0=A0[[m^[[30m^[[40m^[[1m ^[[36m^[[44m^[[K^[[B > [..] > > Dec 14 13:26:48 camtrace13 kernel: Starting slim. > > Dec 14 13:26:48 camtrace13 kernel: Starting > > You'll need to rework this somehow so dialog's stdout isn't written to > /dev/console, though that may seem necessary if you want it coming up on > the VTY0 boot screen. It may involve decoupling this task from running > 'inline' as a boot script somehow, or else making sure that output is > redirected to a log or temporary file instead of directly into dialog. > mmmmkay. It's now fixed. OUT=3D`/sbin/conscontrol | /usr/bin/sed -n 's;^Configured: .*\(tty[^, ]*\).*$;/dev/\1;p'` (is it always /dev/ttyv0? in doubt, I'll trust conscontrol) [...] $DIALOG [...] >$OUT > > > dhclient and oss seem to dump their output in /var/log/messages, while > > apache, postgresql and slim dump their one in /var/log/console.log > > So... How can my rc.script write in both console and messages logs? > > And how can I get rid of that? > > dhclient's (running) output is normally logged to messages, whereas the > 'Starting' messages are output of the rc process as it launches things. > Indeed, my bad. > > And it's only those couple of lines to messages, the rest of them to > console.log is unsurprising and expected if they're written to stdout. > > HTH a bit, Ian Thanks! --=20 Samuel Mart=C3=ADn Moro {EPITECH.} tek5 CamTrace S.A.S (+033) 1 41 38 37 60 1 All=C3=A9e de la Venelle 92150 Suresnes FRANCE "Nobody wants to say how this works. Maybe nobody knows ..." Xorg.conf(5)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinRDa89gH5jXMeDkTbdu9yrLGcNev7YK15dUauw>