Change PostgreSQL service Name - Linux

7.3k Views Asked by At

I have two different PostgreSQL 10 servers running on the same system (using different ports) on a CentOS 6/7 system. Can someone tell me how to name these PostgreSQL services differently? Like when I run a ps on the system, it should show both the services running with different names. Right now it shows both the service names as postgres. Can someone tell me how to rename the postgres service on Linux?

I know how to do that on Windows pg_ctl.exe register -N Postgres_1 (The -N argument lets us choose the name of the Postgres service) So basically when we register the service, we can give it a custom name on Windows... but can someone tell me how to do the same on Linux?

Thanks in advance.

2

There are 2 best solutions below

0
On

If you just want to change the service name (you must know the service name), then here you go-

Browse to the service location and rename it, like this: On Centos 6 :

cd /etc/init.d/
mv postgresql postgresql5432

On Centos 7:

cd /usr/lib/systemd/system
mv postgresql.service postgresql5432.service
systemctl daemon-reload

(I am assuming you know what service is using port no. 5432)

But if you want to just figure out using ps then go for the solution of @Laurenz Albe.

3
On

If you set cluster_name in postgresql.conf, you will see it in the args column of the ps output.