$ systemctl restart postgresql-9.2.24
Failed to restart postgresql-9.2.24.service: Unit not found.
2 Answers
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
[email protected] loaded active running PostgreSQL Cluster 9.3-main
[email protected] 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$
That means that there is no file named
postgresql-9.2.24.service
in your systemd directory.
The exact location varies between Linux distributions, but it is usually /usr/lib/systemd/system or /lib/systemd/system.
whereis,whichandaproposcommands.postgresql-9.2.service(btw: Postgres 9.2 is no longer supported you should plan an upgrade as soon as possible).