I am running a script on my PostgreSQL server:
psql db -f sql.sql
from bash or in a cron script.
It keeps
To disable pagination but retain the output, use:
\pset pager off
To remember this setting, add it to your ~/.psqlrc.
See the psql manual.
On older versions of Pg it was just a toggle, so \pset pager
To completely suppress query output, use \o /dev/null in your psql script.
To suppress psql's informational output, run it with -q or set QUIET=1 in the environment.
To produce results and throw them away you can redirect stdout to /dev/null with:
psql db -f sql.sql >/dev/null
You can redirect both stdout and stderr with:
psql db -f sql.sql >&/dev/null
but I don't recommend that, as it'll throw away error information that might warn you something isn't going right. You're also producing results and throwing them away, which is inefficient; you're better off just not producing them in the first place by adjusting your queries.