2021-09-30

PostgreSQL check config file location

#!/bin/bash
#/postgres/pgscript/postgres-pgdata-LOC.sh
#LastUpdate: #11:35 2021.09.18
################################################
#su - postgres -c 'psql -h 127.0.0.1 -p 5432'
################################################

echo "===================="
echo "PostgreSQL [pgdata] location:..."
su - postgres -c "psql -h 127.0.0.1 -d postgres -c 'show data_directory;'"


echo "===================="
echo "PostgreSQL [config file] location:..."
#SELECT name,setting,category FROM pg_settings WHERE category like '%Locations%';
su - postgres -c "psql -h 127.0.0.1 -d postgres -c \"SELECT name,setting,category FROM pg_settings WHERE category like '%Locations%';\""
#THE_END

#RESULT:
root@srv145:/postgres/pgscript# ./postgres-pgdata-LOC.sh
====================
PostgreSQL [pgdata] location:...
  data_directory  
------------------
 /postgres/pgdata
(1 row)

====================
PostgreSQL [config file] location:...
       name        |             setting              |    category    
-------------------+----------------------------------+----------------
 config_file       | /postgres/pgdata/postgresql.conf | File Locations
 data_directory    | /postgres/pgdata                 | File Locations
 external_pid_file |                                  | File Locations
 hba_file          | /postgres/pgdata/pg_hba.conf     | File Locations
 ident_file        | /postgres/pgdata/pg_ident.conf   | File Locations
(5 rows)

No comments:

Post a Comment