Suppress output from psql?

Started by Ron St-Pierreover 21 years ago7 messagesgeneral
Jump to latest
#1Ron St-Pierre
rstpierre@syscor.com

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

#2Doug McNaught
doug@mcnaught.org
In reply to: Ron St-Pierre (#1)
Re: Suppress output from psql?

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

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ron St-Pierre (#1)
Re: Suppress output from psql?

Ron St-Pierre <rstpierre@syscor.com> writes:

Is there a way 'within' psql to suppress output?

Perhaps "\o /dev/null" ?

regards, tom lane

#4Alvaro Herrera
alvherre@dcc.uchile.cl
In reply to: Doug McNaught (#2)
Re: Suppress output from psql?

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)

#5Scott Gerhardt
scott@g-it.ca
In reply to: Ron St-Pierre (#1)
Re: Suppress output from psql?

You could redirect the output from your cron initiated script with:

Show quoted text

/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

#6John Sidney-Woollett
johnsw@wardbrook.com
In reply to: Ron St-Pierre (#1)
Re: Suppress output from psql?

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:

Show quoted text

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

#7Ron St-Pierre
rstpierre@syscor.com
In reply to: Ron St-Pierre (#1)
Re: Suppress output from psql?

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