Re: Suppress output from psql?

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Doug McNaught <doug(at)mcnaught(dot)org>
Cc: Ron St-Pierre <rstpierre(at)syscor(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Suppress output from psql?
Date: 2004-09-01 03:34:55
Message-ID: 20040901033455.GO6895@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 31, 2004 at 09:00:24PM -0400, Doug McNaught wrote:
> Ron St-Pierre <rstpierre(at)syscor(dot)com> writes:
>
> > Is there a way 'within' psql to suppress output?
> >
> > One of our cron scripts calls a sql file which contains various database
> > commands (ALTER TABLEs, UPDATEs, etc) and various user-defined functions.
> > So within this sql file there are various SELECT * FROM myFunction(); which
> > sends output to the user from cron. I can't see anyway to suppress this from
> > the psql docs and I don't believe that I can suppress it from cron
> > either (I'll do
> > some more checking there).
>
> How about putting ">/dev/null 2>&1" after the command line in your crontab?

This is a bad idea if the command fails ...

> Or redirect it to a file if you think you might need it...

Yeah, redirect it to a temp file (use mktemp) and

if [ $? == 0 ]; then
delete the file
else
cat the file
fi

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"El Maquinismo fue proscrito so pena de cosquilleo hasta la muerte"
(Ijon Tichy en Viajes, Stanislaw Lem)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2004-09-01 03:37:23 Re: Large Databases
Previous Message Tom Lane 2004-09-01 03:34:54 Re: Suppress output from psql?