I do not know the service\'s name, but would like to stop the service by checking its status.
For example, if I want to check if the PostgreSQL service is running or no
There is a simple way to verify if a service is running
systemctl status service_name
Try PostgreSQL:
systemctl status postgresql
Dirty way to find running services. (sometime it is not accurate because some custom script doesn't have |status| option)
[root@server ~]# for qw in `ls /etc/init.d/*`; do $qw status | grep -i running; done
auditd (pid 1089) is running...
crond (pid 1296) is running...
fail2ban-server (pid 1309) is running...
httpd (pid 7895) is running...
messagebus (pid 1145) is running...
mysqld (pid 1994) is running...
master (pid 1272) is running...
radiusd (pid 1712) is running...
redis-server (pid 1133) is running...
rsyslogd (pid 1109) is running...
openssh-daemon (pid 7040) is running...
Maybe what you want is the ps command;
ps -ef
will show you all processes running. Then if you have an idea of what you're looking for use grep to filter;
ps -ef | grep postgres
You can use the below command to check the list of all services.
ps aux
To check your own service:
ps aux | grep postgres
For centos, below command worked for me (:
locate postgres | grep service
Output:
/usr/lib/firewalld/services/postgresql.xml
/usr/lib/systemd/system/postgresql-9.3.service
sudo systemctl status postgresql-9.3.service
Based on this answer on a similar topic https://askubuntu.com/a/58406
I prefer: /etc/init.d/postgres status