1
$ systemctl restart postgresql-9.2.24

Failed to restart postgresql-9.2.24.service: Unit not found.
2
  • Check out the whereis, which and apropos commands. Commented Oct 24, 2019 at 6:44
  • The service name typically does not include the minor version. So the name would be postgresql-9.2.service (btw: Postgres 9.2 is no longer supported you should plan an upgrade as soon as possible). Commented Oct 24, 2019 at 7:18

2 Answers 2

1

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$ 
0
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.