I have a Jenkins server, which periodically rebuilds a PHP/mySQL application. Every time new PHP code is pushed, this job drops all the tables in the corresponding database and then recreates them with the structure specified in the PHP installer. This is working fine for the most part, though occasionally it hangs.

The thing I'm not sure how mysqld/php processes get instantiated/destroyed. I notice I often have php processes that run for over an hour, and I constantly have at least one mysqld process that runs for hours/days. Take a look at my top output:

enter image description here

Aren't you supposed to get a new process each time a page is requested? And isn't that process supposed to be destroyed after the page is delivered? I thought PHP works that way, I'm not sure about mysqld. I do have a line in php.ini that says max_execution_time = 30, so I'm pretty confused how this php process could be going for over an hour.

  • 1
    Can you post the output of ps -ef f?
    – GregL
    Commented Aug 7, 2015 at 15:26
  • @GregL sure! gist.github.com/MKorostoff/92f983593c782a45bd35. A few things to note about this output: it was captured shortly after server reboot (about 25 minutes after rebooting), while two jenkins builds were going on (both builds running very slow, and probably hanging). Commented Aug 7, 2015 at 15:54
  • If a new process was forked for every request, web pages would be horrendously slow. Like 1990s slow. Commented Aug 7, 2015 at 16:51
  • So, @MichaelHampton is that to say the answer to my question is "yes, this is normal"? Commented Aug 7, 2015 at 17:00
  • Yes, it's normal for Apache, PHP and MySQL processes to be around for as long as the server is up and running. Commented Aug 7, 2015 at 17:00

1 Answer 1


Unless you have your Jenkins job configured to start and stop mysqld every time it runs you won't see it disappear from the process list. mysqld is a daemon that runs in the background at all times, depending on how it was configured and installed. A standard package installation will enable the service to start at boot.

Additionally, mysqld will not fork new processes. All queries will be handled by that single process.

As for the PHP process, the top command does not display TIME in real (clock) time. It is reporting CPU time. You can have a process running for several hours yet it has only used a few minutes, or even seconds, of CPU time. Also, it's reporting the CPU time as m:ss.t (minutes:seconds.tenths of a second).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .