Unix Technical Forum

VACUUM VERBOSE output to STDERR

This is a discussion on VACUUM VERBOSE output to STDERR within the Pgsql General forums, part of the PostgreSQL category; --> Hello, I'm trying to solve a little issue: I wish to redirect my cron jobs'output to log files. STDOUT ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 11:59 AM
Francis GUDIN
 
Posts: n/a
Default VACUUM VERBOSE output to STDERR

Hello,

I'm trying to solve a little issue: I wish to redirect my cron
jobs'output to log files. STDOUT redirection is done inside the crontab,
but VACUUM still yields its messages[1] through, onto STDERR, I guess.
I wouldn't like to '2>&1' also: I wish I could keep STDERR (what if an
error condition must be reported ?).
Is there a way to do so ?

Thanks in advance,

BR,
Francis

[1]e.g.:
<snip>
NOTICE: --Relation pg_type--
NOTICE: Pages 3: Changed 0, Empty 0; Tup 145: Vac 0, Keep 0, UnUsed 2.
Total CPU 0.00s/0.00u sec elapsed 0.07 sec.
NOTICE: Analyzing pg_type
NOTICE: --Relation pg_attribute--
NOTICE: Pages 12: Changed 0, Empty 0; Tup 827: Vac 0, Keep 0, UnUsed
32. Total CPU 0.00s/0.00u sec elapsed 0.00 sec.
NOTICE: Analyzing pg_attribute
</snip>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFE3IsEKVkrPtliFQQRArW2AJ0Xil08T4O0pWi2CzgJ6p Pvuzim2ACgk0II
FY+y4fjobWmY1X31rWdDzKQ=
=L3IY
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 11:59 AM
John Purser
 
Posts: n/a
Default Re: VACUUM VERBOSE output to STDERR

On Fri, 11 Aug 2006 15:49:56 +0200
Francis GUDIN <fgudin@cri74.org> wrote:

> Hello,
>
> I'm trying to solve a little issue: I wish to redirect my cron
> jobs'output to log files. STDOUT redirection is done inside the
> crontab, but VACUUM still yields its messages[1] through, onto
> STDERR, I guess. I wouldn't like to '2>&1' also: I wish I could keep
> STDERR (what if an error condition must be reported ?).
> Is there a way to do so ?
>
> Thanks in advance,
>
> BR,
> Francis


Francis,

Take a look at the "tee" command that takes stdin and writes it to
stdout AND a file. If I understand you correctly you DO want to keep
stdout and stderr as two separate streams, write (at least) std err to
a log file, but have the error messages e-mailed to you as part of your
cron job. The command line for that might look something like:

ls tmp/nofile tmp/goodfile 2>&1 1>tmp/nofile.txt | tee tmp/nofile.err

Here I've run the command ls on two files, one that exixts, and one
that doesn't. In the first half (before the pipe or bar) I've
redirected stdout to a file called "nofile.txt" and THEN redirected
stderr to stdout. Redirection is read right to left just to be
exciting.

I pipe the result (stderr on stdout's descriptor) to the tee command
which redirects stdout (stderr from the ls command) to another file
AND prints it to stdout or the screen.

Personally I don't think this is a neat solution but has the virtue of
working. My own understanding of redirection is rudimentary at best.
It's a topic well worth researching on it's own merit.

Good luck.

John Purser

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 11:59 AM
Francis GUDIN
 
Posts: n/a
Default Re: VACUUM VERBOSE output to STDERR

On Fri, 11 Aug 2006 08:05:44 -0700
John Purser <jmpurser@gmail.com> wrote:

> Take a look at the "tee" command that takes stdin and writes it to
> stdout AND a file. If I understand you correctly you DO want to keep
> stdout and stderr as two separate streams, write (at least) std err to
> a log file, but have the error messages e-mailed to you as part of
> your cron job. <snip>


Thanks for your suggestion, but my concern is more about vacuum's
behaviour, in fact:
those messages are purely /informative/ and get sent to STDERR.
This seems wrong to me: 'mundane' activity should be output to STDOUT and
'exceptional conditions' deserve the special fd, don't they ?

Francis

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFE3KwIKVkrPtliFQQRAlzHAKCJmV6eOzrJTAQFR5jRE1 SzwUMU7gCgjb25
rRomprCTyNFVMbA0ZGf70Uk=
=ffVx
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 11:59 AM
Martijn van Oosterhout
 
Posts: n/a
Default Re: VACUUM VERBOSE output to STDERR

On Fri, Aug 11, 2006 at 06:10:48PM +0200, Francis GUDIN wrote:
> On Fri, 11 Aug 2006 08:05:44 -0700
> John Purser <jmpurser@gmail.com> wrote:
>
> > Take a look at the "tee" command that takes stdin and writes it to
> > stdout AND a file. If I understand you correctly you DO want to keep
> > stdout and stderr as two separate streams, write (at least) std err to
> > a log file, but have the error messages e-mailed to you as part of
> > your cron job. <snip>

>
> Thanks for your suggestion, but my concern is more about vacuum's
> behaviour, in fact:
> those messages are purely /informative/ and get sent to STDERR.
> This seems wrong to me: 'mundane' activity should be output to STDOUT and
> 'exceptional conditions' deserve the special fd, don't they ?


Well, I don't think psql or libpq really distinguishes them that much.
Normally you just set client_min_messages to suppress the messages you
don't want.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFE3LWMIB7bNG8LQkwRAv5XAJ0f0dUHFktUNmEkt70vkQ rtkJ0aLQCgjcK9
xsLrweqUYSblixEcbbukEDY=
=MO/N
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:57 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com