Suppress output from psql?

Поиск
Список
Период
Сортировка
Искать

Suppress output from psql?

От:
Ron 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

Re: Suppress output from psql?

От:
Doug McNaught <doug@mcnaught.org>
Дата:
Ron St-Pierre  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?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Ron St-Pierre  writes:
> Is there a way 'within' psql to suppress output?

Perhaps "\o /dev/null" ?

			regards, tom lane

Re: Suppress output from psql?

От:
Scott Gerhardt <scott@g-it.ca>
Дата:
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?

От:
Alvaro Herrera <alvherre@dcc.uchile.cl>
Дата:
On Tue, Aug 31, 2004 at 09:00:24PM -0400, Doug McNaught wrote:
> Ron St-Pierre  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 ()
"El Maquinismo fue proscrito so pena de cosquilleo hasta la muerte"
(Ijon Tichy en Viajes, Stanislaw Lem)

Re: Suppress output from psql?

От:
John Sidney-Woollett <johnsw@wardbrook.com>
Дата:
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?

От:
Ron St-Pierre <rstpierre@syscor.com>
Дата:
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

FAQ