Thread: Suppress output from psql?

Suppress output from psql?

From
Ron St-Pierre
Date:
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).

Thanks
Ron


Re: Suppress output from psql?

From
Doug McNaught
Date:
Ron St-Pierre <rstpierre@syscor.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?

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

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
   --T. J. Jackson, 1863

Re: Suppress output from psql?

From
Tom Lane
Date:
Ron St-Pierre <rstpierre@syscor.com> writes:
> Is there a way 'within' psql to suppress output?

Perhaps "\o /dev/null" ?

            regards, tom lane

Re: Suppress output from psql?

From
Scott Gerhardt
Date:
You could redirect the output from your cron initiated script with:
 > /dev/null 2>&1


> 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).
>
> Thanks
> Ron
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>               http://archives.postgresql.org
>


Re: Suppress output from psql?

From
Alvaro Herrera
Date:
On Tue, Aug 31, 2004 at 09:00:24PM -0400, Doug McNaught wrote:
> Ron St-Pierre <rstpierre@syscor.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)


Re: Suppress output from psql?

From
John Sidney-Woollett
Date:
Checkout http://www.hentzenwerke.com/wp/cron_explained.pdf

Look for the MAILTO="" command which you can use to suppress the mailing
of cron job output.

And try redirecting std output to /dev/null, and/or send the output from
psql to a file.

John Sidney-Woollett

Ron St-Pierre wrote:
> 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).
>
> Thanks
> Ron
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>               http://archives.postgresql.org

Re: Suppress output from psql?

From
Ron St-Pierre
Date:
Ron St-Pierre wrote:

> 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).

Tom, that looks like exactly what I need, I'll try it. Doug, Scott,
Alvaro, John, I don't want to send the entire output
of my cron script to /dev/null, just the parts inside of my misc.sql
file (which cron calls) where I call my own functions,
eg SELECT * FROM myFunction();

Also. I will check out the MAILTO="" which will be helpful for some of
my other cron scripts. Thanks John.

Ron