Checking if service is running


 
Thread Tools Search this Thread
Operating Systems Solaris Checking if service is running
# 1  
Old 04-27-2017
Checking if service is running

Hi,

For audit reasons, I need to stop the web server service in some Solaris servers.
The port that is listening for this service is port 10000.

This is the output that shows the port 10000 is open in the server :

Code:
# netstat -an | grep 10000
10.70.21.144.10000   10.70.21.133.58130   49640      0 49640      0 FIN_WAIT_2
      *.10000              *.*                0      0 49152      0 LISTEN
10.70.21.145.52626   10.70.21.248.10000   17536      0 49640      0 CLOSE_WAIT
#

However, firewall is not even enabled in the server. How come the port shows as listening if the firewall is not even open :

Code:
# svcs -a|grep -i ipfil
disabled       Dec_23   svc:/network/ipfilter:default
#

Seems like apache2 shows disabled :

Code:
# svcs apache2
STATE          STIME    FMRI
disabled       Dec_23   svc:/network/http:apache2
#

Checking for service apache and httpd does not produce any output :

Code:
# svcs httpd
svcs: Pattern 'httpd' doesn't match any instances
STATE          STIME    FMRI

Code:
# svcs apache
svcs: Pattern 'apache' doesn't match any instances
STATE          STIME    FMRI
#

And when I check if apache process is running :

Code:
# ps -ef | grep apache
 sdpuser  1134  1358   0   Apr 26 ?           0:00 /usr/apache/bin/httpd
 sdpuser 22971  1358   0   Apr 26 ?           0:00 /usr/apache/bin/httpd
 sdpuser 10910  1358   0 11:11:14 ?           0:00 /usr/apache/bin/httpd
 sdpuser  1358     1   0   Dec 23 ?           2:25 /usr/apache/bin/httpd
 sdpuser 14745  1358   0 09:41:09 ?           0:00 /usr/apache/bin/httpd
 sdpuser 10915  1358   0 11:11:15 ?           0:00 /usr/apache/bin/httpd
    root  6445  5575   0 14:47:52 pts/5       0:00 grep apache

# ps -ef | grep httpd
 sdpuser  1134  1358   0   Apr 26 ?           0:00 /usr/apache/bin/httpd
 sdpuser 22971  1358   0   Apr 26 ?           0:00 /usr/apache/bin/httpd
 sdpuser 10910  1358   0 11:11:14 ?           0:00 /usr/apache/bin/httpd
 sdpuser  1358     1   0   Dec 23 ?           2:25 /usr/apache/bin/httpd
 sdpuser 14745  1358   0 09:41:09 ?           0:00 /usr/apache/bin/httpd
 sdpuser 10915  1358   0 11:11:15 ?           0:00 /usr/apache/bin/httpd
    root  6463  5575   0 14:48:00 pts/5       0:00 grep httpd
#

I do not understand how the outputs above are related. When I check the status of apache2 with svcs it shows that apache2 is disabled. There is no output for svcs apache & svcs httpd. But ps -ef shows some httpd process. Does this mean that apache/httpd is started in some customized way, and not using svcs?

If so, does killing the process id from the ps -ef output kill the web server process once and for all?

And how do I stop the server from listening to port 10000 when the firewall is not even open? Will killing the process id "49152" do it?

Thanks,
Aigini
# 2  
Old 04-27-2017
Quote:
Originally Posted by anaigini45

I do not understand how the outputs above are related. When I check the status of apache2 with svcs it shows that apache2 is disabled. There is no output for svcs apache & svcs httpd. But ps -ef shows some httpd process. Does this mean that apache/httpd is started in some customized way, and not using svcs?
Likely "apachectl start"
Quote:
If so, does killing the process id from the ps -ef output kill the web server process once and for all?
Yes, although "apachectl stop" would be a cleaner way to stop it.
Quote:
And how do I stop the server from listening to port 10000 when the firewall is not even open?
A firewall doesn't prevent a process to listen to whatever port, it might just prevent some or all traffic to reach that port.
Quote:
Will killing the process id "49152" do it?
There is no process 49152 involved here but in any case, killing whatever process wouldn't change the fact apache listens on port 10000.
# 3  
Old 04-27-2017
Thank you, for the information.
However, is there a command that can stop the server from listening to port 10000?

I need to stop the listening on this port.
# 4  
Old 04-27-2017
A good tool is lsof used like this:-
Code:
lsof -i tcp:10000

You will get a few lines of output and the PID should be obvious. Be careful, because you will also list processes connected to remote port 10000 too.


I hope that this helps,
Robin
# 5  
Old 04-27-2017
Quote:
Originally Posted by anaigini45
Thank you, for the information.
However, is there a command that can stop the server from listening to port 10000?

I need to stop the listening on this port.
If the issue is about this port number specifically, you can configure apache to listen to a different TCP port by editing the /etc/apache2/httpd.conf file (or a file referenced by it), "Listen" directive.

Otherwise, there is no way to configure apache not to listen on any port, which would be quite pointless, just stop the server.

---------- Post updated at 17:56 ---------- Previous update was at 17:51 ----------

Quote:
Originally Posted by rbatte1
A good tool is lsof
As long as it is installed which is often not the case, "lsof" not being part of Solaris distributions. See How to install pkg lsof in Solaris 11?, especially the last posting.
# 6  
Old 04-29-2017
If you're on Solaris 11.2 or later
Code:
netstat -aun

will show what PID is attached to all network objects (listening on ports, connected, etc) along with the base name of the process executable.
This User Gave Thanks to achenle For This Post:
# 7  
Old 04-29-2017
and for older releases, "pfiles -p pid" can be used to confirm what ports, if any, a given process is listening to.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking to see if windows service is running

Hi I have created a PowerShell script which successfully checks whether windows service pgsql-9.2 is running. I have tried to call that PowerShell script with a shell/bash script within a LINUX machine but have been unsuccessful. Is there a way of a shell/Perl script to check whether a... (5 Replies)
Discussion started by: simpsa27
5 Replies

2. Red Hat

How a service is always running ?

Hi How ssh service at all levels always running in her file /etc/inittab? vi /etc/inittab 10::respawn:/etc/init.d/sshd I added this line & save run init q But it did not (6 Replies)
Discussion started by: mnnn
6 Replies

3. Shell Programming and Scripting

Service checking through shell script

I want to check the postgres service for client PC which is remotely placed through shell script , whether the Postgres service is working or not.I don't have an idea to develop this script.Please give me a code. Client PC IP Address: 10.66.1.133 (2 Replies)
Discussion started by: kannansoft1985
2 Replies

4. UNIX for Dummies Questions & Answers

FIFO Status Checking/Running

May i please know 1) How to check if FIFO process is down? 2) How to bring FIFO up and running? we are using redhat Linux OS and bash shell Thank you. (1 Reply)
Discussion started by: Ariean
1 Replies

5. Shell Programming and Scripting

checking to see if a service is running in a shell script

How can I tell, in a shell script, if a certain service is running? I know how to do this on the command line, but not in a script. Is an error thrown somehow that I can check? Thanks. (6 Replies)
Discussion started by: daflore
6 Replies

6. Shell Programming and Scripting

Checking availability of service

HI CAN ANY ONE HELP ME FOR BELOW QUESTION CHECKING AVAILABILITY OF SERVICE IN LINUX (2 Replies)
Discussion started by: satheeshkr_cse
2 Replies

7. Shell Programming and Scripting

Network checking while running a script

hi, i am new to this scripting stuff so please help. i need a script that should check network connection while process.bsh is running which connects to a server for some time (e.g. 30 secs to a minute) and I wanted to make sure that network interruption does not happen during this time period... (2 Replies)
Discussion started by: bun $ ny
2 Replies

8. Windows & DOS: Issues & Discussions

Checking Current Service Pack & Hot Fixes of XP

Dear Sir / Madam, With due respect, I am putting forwarad a question that whenever I am trying to check the current Service Pack & Hotfixes in Windows XP, I am getting the response like as under: (Windows can't find the" qfecheck.exe " check it again) in GUI mode ... (1 Reply)
Discussion started by: swapan
1 Replies

9. UNIX for Dummies Questions & Answers

daemon running in AIX checking

how do u check if a daemon is running in AIX.. Is it ps -ef|grep daemon lssrc -s demon ??? Thanks! (0 Replies)
Discussion started by: karthikosu
0 Replies

10. Solaris

How to be sure the dns service is running ?

Well, i changed my lan card and finally i got it up and running, i have /etc/resolv.conf with domain xxx.xxx nameserver xxx.xxx.xxx.xxx and it was working with me earlier with the old lan card, with the new one i added it ip using auto-dhcp and its received an ip from my dhcp and it can ping... (4 Replies)
Discussion started by: XP_2600
4 Replies
Login or Register to Ask a Question