From: | John Purser <jmpurser(at)gmail(dot)com> |
---|---|
To: | Francis GUDIN <fgudin(at)cri74(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: VACUUM VERBOSE output to STDERR |
Date: | 2006-08-11 15:05:44 |
Message-ID: | 20060811080544.c49c9499.jmpurser@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 11 Aug 2006 15:49:56 +0200
Francis GUDIN <fgudin(at)cri74(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2006-08-11 15:06:42 | Re: [GENERAL] different sort order in windows and linux |
Previous Message | Merlin Moncure | 2006-08-11 14:41:56 | Re: Tuning to speed select |