Postgresql – How to do Postgresql 9.2 version check in Linux

postgresqlpostgresql-9.2startup

$ systemctl restart postgresql-9.2.24

Failed to restart postgresql-9.2.24.service: Unit not found.

Best Answer

Just run:

systemctl  | grep postgres

... and you'll be able to see what the service is actually called.

For example:

phil@ironforge:~/M$ systemctl  | grep postgr
  postgresql.service                                                loaded active exited    PostgreSQL RDBMS
  postgresql@9.3-main.service                                       loaded active running   PostgreSQL Cluster 9.3-main
  postgresql@9.5-main.service                                       loaded active running   PostgreSQL Cluster 9.5-main
  system-postgresql.slice                                           loaded active active    system-postgresql.slice
phil@ironforge:~/M$ 

So, in this case, I can just use:

systemctl restart postgresql

eg:

phil@ironforge:~/M$ systemctl restart postgresql
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'postgresql.service'.
Authenticating as: root
Password: *******
==== AUTHENTICATION COMPLETE ===
phil@ironforge:~/M$