0
1
At UBUNTU, service postgresql status
lists
Process: 18534 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 18534 (code=exited, status=0/SUCCESS)
but when I test sudo ps -ax | grep 18534
nothing is listed.
NOTES
EDIT1 for @DanielB request, but I need a simple command that shows any service PID.
Here a dump more /lib/systemd/system/postgresql.service
,
# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded.
[Unit]
Description=PostgreSQL RDBMS
[Service]
Type=oneshot
ExecStart=/bin/true
ExecReload=/bin/true
RemainAfterExit=on
[Install]
WantedBy=multi-user.target
EDIT2
The PostgreSQL above was my localhost server... Now I am testing in a "new, clean and shine" DigitalOcean Droplet with UBUNTU 16 LTS and Postgresql 9.X...
root@myServer:~# service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Dom 2016-12-18 17:47:09 UTC; 2 weeks 4 days ago
Main PID: 8703 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
CGroup: /system.slice/postgresql.service
Dez 18 17:47:09 myServer systemd[1]: Starting PostgreSQL RDBMS...
Dez 18 17:47:09 myServer systemd[1]: Started PostgreSQL RDBMS.
Dez 18 17:47:14 myServer systemd[1]: Started PostgreSQL RDBMS.
root@myServer:~# sudo ps -ax | grep 8703
3702 pts/0 S+ 0:00 grep --color=auto 8703
root@myServer:~# sudo service postgresql restart
root@myServer:~# sudo ps -ax | grep 8703
3760 pts/0 S+ 0:00 grep --color=auto 8703
root@myServer:~# service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Sex 2017-01-06 16:06:07 UTC; 8s ago
Process: 3755 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 3755 (code=exited, status=0/SUCCESS)
Jan 06 16:06:07 myServer systemd[1]: Starting PostgreSQL RDBMS...
Jan 06 16:06:07 myServer systemd[1]: Started PostgreSQL RDBMS.
sudo ps -ax | grep 3755
3780 pts/0 S+ 0:00 grep --color=auto 3755
Well,
/bin/true
is obviously not the service. It’s also marked as exited. Please provide the contents of/lib/systemd/system/postgresql.service
. – Daniel B – 2017-01-06T14:56:07.780Hi @DanielB, I Edited with the dump. – Peter Krauss – 2017-01-06T15:03:07.643
For other service, as
service postfix status
it is ok (!). The problem with PostgreSQL is perhaps a kind of "thread activation"... Perhaps I need the service in use attop
, is it? – Peter Krauss – 2017-01-06T15:06:55.747“I need a simple command that shows any service PID.” – That’s probably not going to happen. That being said, what the f is this. – Daniel B – 2017-01-06T15:07:29.703
1It seems to me that
postgresql
is not running. Processes have exit code after they exited, it makes no sense to mention exit code of a currently running process. – janos – 2017-01-06T15:22:42.1131@janos This service does obviously not start PostgreSQL. It is part of some sort of bad hack. – Daniel B – 2017-01-06T15:50:32.637
http://serverfault.com/questions/818838/postgresql-exits-after-being-started This explains what’s going on. I still think it’s bs. – Daniel B – 2017-01-06T15:56:59.833
@janos the service is alive, as I showed (and now confirm). ... I not know the behaviour of daemon (and its PIDs), perhaps we need better knowledge about it... As link above of Daniel. – Peter Krauss – 2017-01-06T16:03:51.457
@PeterKrauss you didn't show it is alive. You could try something though. What port is the service listening on? If you are on Linux (please confirm), then you can verify the port is up by running
sudo netstat -ntlp | grep :the-port-number
. This command will also show the process id. Include this info in your question. – janos – 2017-01-06T16:06:47.257Thanks @janos, see my EDIT2. About port:
sudo netstat -ntlp | grep 5432
showstcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 3738/postgres
(for both machines). – Peter Krauss – 2017-01-06T16:14:25.493@janos yes! you find, "LISTEN 3738/postgres" is the PID! ...
sudo ps -ax | grep 3738
now returns3738 ? S 0:00 /usr/lib/postgresql/9.5/bin/postgres -D /var/lib/postgresql/9.5/main -c
– Peter Krauss – 2017-01-06T16:16:48.263