How to check if a particular service is running on Ubuntu

前端 未结 13 1918
猫巷女王i
猫巷女王i 2021-01-29 17:48

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

13条回答
  •  广开言路
    2021-01-29 17:57

    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...
    

提交回复
热议问题