{"id":182,"date":"2021-03-25T08:14:05","date_gmt":"2021-03-25T08:14:05","guid":{"rendered":"https:\/\/codedrill.in?p=182"},"modified":"2022-04-07T12:12:12","modified_gmt":"2022-04-07T12:12:12","slug":"linux-find-php-file-by-process-id","status":"publish","type":"post","link":"https:\/\/codedrill.in\/linux-find-php-file-by-process-id\/","title":{"rendered":"Linux find php file by process id"},"content":{"rendered":"\n<p>Sometimes on dedicated hosting, there can be some scripts that will start consuming 100% of CPU and all the websites will stop working. <\/p>\n\n\n\n<p>We can find out the process list using this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>top -i<\/code><\/pre>\n\n\n\n<p>It will tell us the process id, but still, we won&#8217;t be able to find out which PHP file might have created this process.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lsof -p PID(process id which is taking up cpu)<\/code><\/pre>\n\n\n\n<p>This will show a list of files that are using this particular process. And anything matching your apache root directory (mostly \/var\/www\/html\/&#8230;.) is the culprit.<\/p>\n\n\n\n<p>** you might need to install lsof using :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install lsof<\/code><\/pre>\n\n\n\n<p><strong>Related article:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-codedrill-in wp-block-embed-codedrill-in\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/codedrill.inubuntu-kill-all-processes-and-reload-php-fpm\/\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes on dedicated hosting, there can be some scripts that will start consuming 100% of CPU and all the websites will stop working. We can find out the process list using this command: It will tell us the process id, but still, we won&#8217;t be able to find out which PHP file might have created [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,6,13,7],"tags":[],"class_list":["post-182","post","type-post","status-publish","format-standard","hentry","category-apache","category-cpanel","category-linux","category-php"],"_links":{"self":[{"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/posts\/182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/comments?post=182"}],"version-history":[{"count":3,"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/posts\/182\/revisions"}],"predecessor-version":[{"id":716,"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/posts\/182\/revisions\/716"}],"wp:attachment":[{"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/media?parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/categories?post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codedrill.in\/wp-json\/wp\/v2\/tags?post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}