I'm running Debian Stretch and PostgreSQL 10 from apt.postgresql.org. When I do:
postgresql disable --now postgresql
the database server doesn't stop. It says:
Synchronizing state of postgresql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable postgresql
insserv: warning: current start runlevel(s) (empty) of script `postgresql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `postgresql' overrides LSB defaults (0 1 6).
But that probably of not much importance.
systemctl disable --now postgresql@10-main
does the job, but I'm curious about postgresql
unit. Its start
, stop
, restart
, reload
tasks work fine.
Am I missing something? Is this a bug or limitation of systemd
? Or of PostgreSQL package?
And now that I look into it, systemctl disable postgresql
doesn't prevent PostgreSQL from starting on boot. I'd like not to be tied to a particular version. I thought stopping and disabling PostgreSQL would be simply a matter of doing systemctl disable --now postgresql
. But it turns out I've got to:
systemctl list-units 'postgresql*' \
| grep ^postgresql \
| awk '{print $1}' \
| xargs -r -I{} -d\\n systemctl disable --now {}
And even that doesn't always work for some mysterious reasons. I have a copy of data dir for testing purposes. Then in a script I restore database to initial state (stop, rm, cp, start). After which I'm trying to stop and disable pg as above. It gets disabled, but doesn't stop. I can see all it's processes running before the command, I can see:
database system is ready to accept connections
in the log (supposedly fully started). But it just wouldn't. So right now I do:
systemctl stop postgresql
systemctl list-units ... | xargs ... systemctl disable {}
From the man page:
--now When used with enable, the units will also be started. When used with disable or mask, the units will also be stopped. The start or stop operation is only carried out when the respective enable or disable operation has been successful.
0 Answers