Skip to main content

CentOS | RHEL: Check If A Service Is Running Or Not


We can use service command to get the status of services running on the system. It runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /.


Syntax is:


service <service-name> status


OR


/etc/init.d/<service-name> status


Example:


Find, out if a service called httpd (Apache Web Server) is running on CentOS OR RHEL. Open a terminal or login using ssh, enter:


  #  service httpd status


Sample outputs:


[root@myserver ~]# service httpd status


httpd (pid  21585) is running...

Find out status of all services

The service --status-all command runs all init scripts, in alphabetical order, with the status command:
 #  service --status-all
Sample output:-


[root@myserver ~]# service --status-all

anacron is stopped

atd is stopped

auditd is stopped

cpuspeed is stopped

crond (pid 3442) is running...

cupsd (pid 5004) is running...

gpm (pid 3316) is running...

hald is stopped

httpd is stopped

ipmi_msghandler module not loaded.

ipmi_si module not loaded.

ipmi_devintf module not loaded.

/dev/ipmi0 does not exist.

Firewall is stopped.

irqbalance (pid 3031) is running...

Usage: jboss {start|stop|restart}

Usage: jboss {start|stop|restart}

mdmpd is stopped

dbus-daemon-1 is stopped

/etc/init.d/microcode_ctl: reading microcode status is not yet supported

Server address not specified in /etc/sysconfig/netdump

netplugd is stopped

Configured devices:

lo eth0

Currently active devices:

lo eth0

NetworkManager is stopped

nscd is stopped

ntpd (pid 3117) is running...

rhnsd (pid 3498) is running...

saslauthd is stopped

sendmail (pid 3145 3135) is running...

smartd is stopped

snmpd (pid 5035) is running...

snmptrapd is stopped

sshd (pid 32692 32690 31125 31123 31007 31005 28859 28828 27800 27797 25769 25763 24868 24865 24453 24451 23420 23417 22077 22072 21991 21989 21578 21576 21185 21183 20987 20984 20757 20755 20665 20661 19843 19837 18508 18490 18447 18445 15355 15349 15268 15266 11588 11580 11106 11104 8560 8557 8494 8428 8426 8425 8408 7597 7591 7450 7448 6677 6671 5249 5233 4776 4772 4570 4563 3084 2807 2805 2307 2305 1909 1907 1548 1545) is running...

syslogd (pid 3014) is running...

klogd (pid 3018) is running...

vsftpd is stopped

winbindd is stopped

wpa_supplicant is stopped

xfs (pid 3463) is running...

xinetd (pid 4898) is running...


ps or pgrep command

You can use ps or pgrep command as follows to find out if service is running or not on RHEL/Centos:
 #  ps aux | grep 'serviceName'
 # ps aux | grep 'httpd'


Comments

Popular posts from this blog

CentOS / Redhat : Configure CentOS as a Software Router with two interfaces

Linux can be easily configured to share an internet connection using iptables. All you need to have is, two network interface cards as follows: a) Your internal (LAN) network connected via eth0 with static ip address 192.168.0.1 b) Your external WAN) network is connected via eth1 with static ip address 10.10.10.1  ( public IP provided by ISP ) Please note that interface eth1 may have public IP address or IP assigned by ISP. eth1 may be connected to a dedicated DSL / ADSL / WAN / Cable router: Step # 1: Enable Packet Forwarding Login as the root user. Open /etc/sysctl.conf file # vi /etc/sysctl.conf Add the following line to enable packet forwarding for IPv4: net.ipv4.conf.default.forwarding=1 Save and close the file. Restart networking: # service network restart Step # 2: Enable IP masquerading In Linux networking, Network Address Translation (NAT) or Network Masquerading (IP Masquerading) is a technique of transceivin

Virtual Box and Alt/Tab Keys

I use virtual box for all my testing activities. It comes too often that I have a virtual box VM window open & I want to switch to my host machine to see some stuff like tutorials etc.. If you press the alt+tab combination it just works inside the VM & doesn't switches to host machine. In these scenarios you can press the host key once ( not hold it ) & then whatever you press goes to host machine. So in general where host key is the default Right Ctrl, just press Right Ctrl once & now press the alt+tab & it will switch you out to host machine. This is really helpful when you have the VM windows open or you're working on seamless mode. Hope it help others too.

AMD Radeon™ HD 7670M on Ubuntu 12.04

Update:   Recently I install kubuntu 13.10 and there is no problem with graphics. It just works  fine out of the box. I've seen many blog posts on how to make AMD HD7670M work on Ubuntu 12.04, specially when its in switchable graphics board like Dell Inspiron 15R 5520. I tried many things to make it work so that I could use the cinnamon desktop on ubuntu & other things too.. But to my surprise even the drivers from AMD site didn't work. Then I tried a combination of those blog posts I read & somehow I became successful in running the full graphics including compiz settings inside My Ubuntu Machine. Following are the steps I followed & it worked... 1. Create a backup of your xorg configuration file: sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK 2. Remove/purge current fglrx and fglrx-amdcccle : sudo apt-get remove --purge fglrx* 3. Install the driver: sudo apt-get install fglrx fglrx-amdcccle 4. Install additional