How to close connection using psql when executed from shell script
1 Answer
If you run
psql -c '/* SQL statement */'
or
psql -f script.sql
the connection will automatically be closed as soon as the command is done
2 Comments
Naveen Suryawanshi
Laurenz Albe, Thanks for your answer, i have scheduled job through jenkins, which hit my postgres DB in every 1 hour and in between i am getting this error "Failed to get SSH fingerprint from DB: pq: remaining connection slots are reserved for non-replication superuser connections" I doubt it could be because script does not closing the connection. according to your answer, it should close the connection, any idea why i am getting this error?
Laurenz Albe
There are many other connections to the database. Examine
pg_stat_activity to find out where they come from.