1
$ systemctl restart postgresql-9.2.24

Failed to restart postgresql-9.2.24.service: Unit not found.
  • Check out the whereis, which and apropos commands. – Vérace Oct 24 '19 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). – a_horse_with_no_name Oct 24 '19 at 7:18
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
  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$ 
  • This works fine. thanks yaar. happy coding ! – Sunil Vijay Oct 24 '19 at 10:03
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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.