From owner-freebsd-questions@FreeBSD.ORG Wed Dec 15 14:43:11 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 624DD106564A for ; Wed, 15 Dec 2010 14:43:11 +0000 (UTC) (envelope-from faust64@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0C0668FC0C for ; Wed, 15 Dec 2010 14:43:10 +0000 (UTC) Received: by qwj9 with SMTP id 9so2048132qwj.13 for ; Wed, 15 Dec 2010 06:43:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=bV2xoD29YZCjJflgpy7Q99ZlB3C0W0iHJMciZSXIe+Q=; b=cbaWmvdF0AAhb5w28krzpTilkuKLNLqrsVbUm3gaKbr9W3TEQZR9UI/3F6GXxaqz7g 2Q2XbjnKRS/528dUUBc8DpP0Txrl5rwglf8jtH5jqnujRxRiO0NhUnkfRSwMySG0XE5O RDtkBiW1t2okw2KmV8b/tknoVHqHo+/a8WXKc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=I8DAb3fj++Dv0i5U8oNKYvhZ7B2MuFaVBHgXWKwyKEVnk6ujO/l9Tx6DQkGQDx7lyb 4aIyez0GX7x7bb4o3BFdr2Jrym7qo9saqVOcyxKI9j4svGKfY2//k6gyqvJEBSjMBug0 Qz3isIk/xeIQmOj+zkVA87vqteQ+G9t/n63kA= Received: by 10.229.235.142 with SMTP id kg14mr609211qcb.133.1292424189834; Wed, 15 Dec 2010 06:43:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.235.148 with HTTP; Wed, 15 Dec 2010 06:42:29 -0800 (PST) In-Reply-To: <20101215140116.M83735@sola.nimnet.asn.au> References: <20101214180343.F008310656F6@hub.freebsd.org> <20101215140116.M83735@sola.nimnet.asn.au> From: =?ISO-8859-1?Q?Samuel_Mart=EDn_Moro?= Date: Wed, 15 Dec 2010 15:42:29 +0100 Message-ID: To: Ian Smith Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org Subject: Re: boot, rc script and logs X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Dec 2010 14:43:11 -0000 On Wed, Dec 15, 2010 at 4:57 AM, Ian Smith wrote: > In freebsd-questions Digest, Vol 341, Issue 3, Message: 17 > On Tue, 14 Dec 2010 19:02:54 +0100 Samuel Mart?n Moro > 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)