There are special systemd services called template services.
A template service can take an argument like this: template_service@argument
.
A template service is never started in itself, but it can be instantiated with a given argument. This means that the same (template) service may be running in multiple instances, each identified by its argument. For example:
systemctl start template_service@a
systemctl start template_service@b
systemctl start template_service@c
In Debian and some derivative distributions (such as Ubuntu):
Every PostgreSQL instance (cluster) belongs to an instantiated postgresql@
template service. The argument to the postgresql@
service takes the form of version-clustername
.
So for example postgresql@12-main
is a systemd service which represents a PostgreSQL 12 server instance (cluster), with the cluster name main
(which is the default).
There is another systemd service called simply postgresql
. This is a kind of a catch-all service. If you start or stop it, all PostgreSQL instances will be started or stopped (this behavior can be disabled in start.conf
).
You cannot, however, use systemctl status postgresql
to check whether any PostgreSQL services are running, even if you only have a single PostgreSQL server set up in your system. You should always check the status of the particular instantiated service for a meaningful status report.
The service
command was used for the old init system (SysV init), before systemd came along. It still works for backward compatibility, but you really should use the systemctl
command on systems where systemd is available.