Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by BharathKumarRaju DasaraRaju
at 2024-08-01 21:51:59
Point:500 Replies:3 POST_ID:828660USER_ID:11540
Topic:
Linux;Unix Operating Systems;Linux Distributions
First step:
==============>
I have checked what are the apache processes running on my machine as below
[root@localhost ~]# ps -eaf | grep -i httpd
root 2111 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2118 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2119 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2120 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2121 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2122 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2123 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2124 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2125 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
root 3254 3054 0 21:13 pts/2 00:00:00 grep -i httpd
One root owned process and remaining are the apache owned processes.By observing the PPID's of all i came to know that if we kill 2111 then all apache services will killed. So that i did the below action.
[root@localhost ~]# ps -eaf | grep -i httpd | grep "<1>"
root 2111 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
[root@localhost ~]# ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}'
2111
[root@localhost ~]# x=`ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}'`
[root@localhost ~]# echo $x
2111
[root@localhost ~]# kill -9 $x
After that i checked suddenly what happens is all the processes are now owned by the init(PID-1) as below. I surprised :( :( could you explain why? see below output.
[root@localhost ~]# ps -eaf | grep -i httpd
apache 2118 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2119 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2120 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2121 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2122 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2123 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2124 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2125 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
so that again i executed to kill the above processes since all were dummy as below
[root@localhost ~]# ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}'
2118
2119
2120
2121
2122
2123
2124
2125
[root@localhost ~]# ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}' | xargs kill -9
[root@localhost ~]# ps -eaf | grep -i httpd
root 3362 3324 0 21:27 pts/3 00:00:00 grep -i httpd
[root@localhost ~]#
but i have an error showing as below....
[root@localhost ~]# service httpd status
httpd dead but pid file exists
[root@localhost ~]#
could you explain me why?
My aim is to create a script which will clear all the dummy processes which will run by root after stopping the apache.....my script will execute in the below order.
order1 : stopping the apache
order 2 : my own script which idenfies the dummy processes and kills it
my own script contains single line : ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}' | xargs kill -9
order 3 : starting the apache without any issues.
Could you please advise me my script will workout or not?
==============>
I have checked what are the apache processes running on my machine as below
[root@localhost ~]# ps -eaf | grep -i httpd
root 2111 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2118 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2119 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2120 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2121 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2122 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2123 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2124 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2125 2111 0 19:31 ? 00:00:00 /usr/sbin/httpd
root 3254 3054 0 21:13 pts/2 00:00:00 grep -i httpd
One root owned process and remaining are the apache owned processes.By observing the PPID's of all i came to know that if we kill 2111 then all apache services will killed. So that i did the below action.
[root@localhost ~]# ps -eaf | grep -i httpd | grep "<1>"
root 2111 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
[root@localhost ~]# ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}'
2111
[root@localhost ~]# x=`ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}'`
[root@localhost ~]# echo $x
2111
[root@localhost ~]# kill -9 $x
After that i checked suddenly what happens is all the processes are now owned by the init(PID-1) as below. I surprised :( :( could you explain why? see below output.
[root@localhost ~]# ps -eaf | grep -i httpd
apache 2118 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2119 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2120 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2121 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2122 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2123 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2124 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
apache 2125 1 0 19:31 ? 00:00:00 /usr/sbin/httpd
so that again i executed to kill the above processes since all were dummy as below
[root@localhost ~]# ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}'
2118
2119
2120
2121
2122
2123
2124
2125
[root@localhost ~]# ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}' | xargs kill -9
[root@localhost ~]# ps -eaf | grep -i httpd
root 3362 3324 0 21:27 pts/3 00:00:00 grep -i httpd
[root@localhost ~]#
but i have an error showing as below....
[root@localhost ~]# service httpd status
httpd dead but pid file exists
[root@localhost ~]#
could you explain me why?
My aim is to create a script which will clear all the dummy processes which will run by root after stopping the apache.....my script will execute in the below order.
order1 : stopping the apache
order 2 : my own script which idenfies the dummy processes and kills it
my own script contains single line : ps -eaf | grep -i httpd | grep "<1>" | awk '{ print $2}' | xargs kill -9
order 3 : starting the apache without any issues.
Could you please advise me my script will workout or not?
Author: BharathKumarRaju DasaraRaju replied at 2024-08-06 07:12:10
@duncanb7
Thank you so much for your reply......since i was in a vacation iam not able to answer you..thank you so much
Thank you so much for your reply......since i was in a vacation iam not able to answer you..thank you so much
Expert: Tintin replied at 2024-08-01 22:50:54
The reason you end up with a whole bunch of orphaned apache processes is that you kill the main apache process (2111) with a
kill -9
This doesn't give the process a chance to clean up the children as it kills it immediately.
Orphaned processes are then reaped by the init process.
Why don't you just use the standard method of stopping apache?
kill -9
This doesn't give the process a chance to clean up the children as it kills it immediately.
Orphaned processes are then reaped by the init process.
Why don't you just use the standard method of stopping apache?
Accepted Solution
Expert: duncanb7 replied at 2024-08-01 22:09:43
500 points GOOD
Why you kill root httpd ?
=========================
find where the exact httpd.pid file location is and then
kill -TERM `cat /usr/local/apache/logs/httpd.pid` ( which is my system httpd.pid location)
that can kill root httpd and other dummy http process
and you can check it by re-run following command again
ps -eaf | grep -i httpd
and check the file (cat /usr/local/apache/logs/httpd.pid) is empty
=========================
find where the exact httpd.pid file location is and then
kill -TERM `cat /usr/local/apache/logs/httpd.pid` ( which is my system httpd.pid location)
that can kill root httpd and other dummy http process
and you can check it by re-run following command again
ps -eaf | grep -i httpd
and check the file (cat /usr/local/apache/logs/httpd.pid) is empty