How to terminate a process(httpd) when its PID keeps on changing in CENTOS 7
Solution 1
You have to understand that when you grep httpd
you'll not just get back any apache processes but the grep process as well. You're seeing your own command reflected back at you.
# ps ax | grep httpd
1818 ? Ss 0:53 /usr/sbin/httpd
38729 ? S 4:38 /usr/sbin/httpd
38730 ? S 4:49 /usr/sbin/httpd
54915 pts/0 S+ 0:00 grep httpd
Solution 2
Try:
find / -name "httpd.pid"
Then delete the pid file, if it exists.
Also, just in case:
systemctl stop httpd
systemctl disable httpd
Machavity is right too, whenever you grep from the output of ps you're going to see your grep command too. It's something you'll get used to.
Related videos on Youtube
Anup Sharma
Updated on September 18, 2022Comments
-
Anup Sharma over 1 year
When I tried to restart my httpd service using
systemctl restart httpd
Checking the status, I found that process is dead and another process is running. so I removed it using
yum erase httpd
As a precaution, I checked if the process is still running using
ps aux | grep httpd#
and found it was but this time the PID was different. and after subsequent queries, the PID kept on changing. If I try to kill using any PID, it would sayNO Such Process
Check the screenshot:
Hence the question. How do I stop this process so that I can install the service from scratch and configure it?
-
Andrés Sánchez García almost 9 yearsThis PID isn't http process. This PID is grep proccess. Try "systemctl status httpd" for check httpd status. But if you erase httpd package, you haven't any process of httpd
-
Anup Sharma almost 9 yearsExactly my question. When i have already erased the httpd package, how am I getting httpd (pid 22595) already running .
-
faker almost 9 yearsYou also grep for
httpd#
including the#
. Remove the#
to actually properly match for httpd.
-
-
Anup Sharma almost 9 yearsUnserstood. But still if I try systemctl status httpd , I get the same error as httpd (pid 22595) already running and Failed to start The Apache HTTP Server.
-
Machavity almost 9 yearsTry this instead
service httpd status
-
Anup Sharma almost 9 yearsSame Error. Also when I try to kill 22595, it says NO such process
-
Machavity almost 9 yearsMy best guess then is that the httpd.pid file still exists and the system is returning that. Since your
grep
is empty you might want to make sure that file was deleted -
Machavity almost 9 yearsMine lives at
/var/run/httpd/httpd.pid
-
Anup Sharma almost 9 yearsHmmm, no such folder as httpd in run. So could it be any other error?
-
Machavity almost 9 yearsBeyond rebooting I don't have any other suggestions
-
Anup Sharma almost 9 yearsTried that but didn't work. @Machavity 's suggestion of restart worked.