I've installed PostgreSQL under Ubuntu 20.4 using the PGDG apt repository.

Each time I stop the DB server, e.g., with sudo service postgresql stop, the log says 'received fast shutdown request', but I'd like to initiate a smart shutdown.

I can achieve this by sending a TERM signal directly to the postmaster process. However, that seems to circumvent the whole systemd infrastructure. Ideally, I guess, there should be some version of sudo systemctl stop postgresql .... But whatever I try, it always results in a fast shutdown.

Even the less high-level commands don't perform a smart shutdown - contrary to their documentation. Among other variations, I tried

sudo pg_ctlcluster --mode smart 13 main stop
sudo pg_ctlcluster 13 main stop -- --mode smart

and also editing /etc/postgresql/13/main/pg_ctl.conf. All to no avail.

So, what's the proper systemd-conform way to perform a smart shutdown?

  • Write a drop-in service file that changes the way systemd shuts down PostgreSQL. Feb 21, 2022 at 20:38

1 Answer 1


In Debian / Ubuntu systems you need to add the option --skip-systemctl-redirect to the pg_ctlcluster command. Otherwise, the call to postgres will go through systemd, which can not handle shutdown mode.

From your example, it should be like:

sudo pg_ctlcluster --mode smart 13 main stop --skip-systemctl-redirect

Your Answer

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

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