Sometimes, you may discover that one or two your critical services such as Apache (httpd) or mysql has stopped responding. You logged into the terminal and issue the service status command:
[root@srv10]# service httpd status httpd dead but pid file exists
You tried to restart it by issuing the command – # service httpd start
But nothing happens because “httpd is dead but pid file exists”.
What happened? When a process (or a service/daemon) is shutdown properly, it will remove all the relevant ‘pid’ (process ID) and lock files and exit gracefully. But if a process is terminated for some reason or other, it may not have the time to remove the various pid and/or lock files – when this happens, you’ll have to manually remove them.
In CentOS, the ‘pid’ files are often located at:
# cd /var/run/
# cd httpd && ls -l
You will see the file ‘httpd.pid’ in this directory. Delete it.
Try restarting Apache again:
[root@srv10 httpd]# service httpd status httpd dead but subsys locked
If you see the “httpd dead but subsys locked”, you need to remove another file manually:
# cd /var/lock/subsys
# rm -rf httpd
# service httpd start
Now, you should be able to restart Apache (httpd) or the previously ‘dead’ service.