5

I am trying to restart Apache on my server but it does not seem to kill all the processes that Apache is currently running.

The command I am using is

sudo /etc/init.d/apache2 restart

Is there something else I should be doing that will kill all the child processes too?

Thanks

Josh Pennington

Josh Pennington
  • 288
  • 1
  • 6
  • 21
  • What kind of processes aren't killed that should be? CGI scripts? Other subprocesses? Also, what operating system are you running? – Wolph Aug 10 '10 at 22:26
  • From his provided command (apache2) I'd guess it's Debian based, and the fact that he's using sudo automatically for root privileges (rather than the root shell) suggests Ubuntu to me, but I could be wrong. – James L Aug 10 '10 at 22:38
  • Sorry for the lack of detail. I am running the command from the command line and the OS is Debian. – Josh Pennington Aug 10 '10 at 22:43

3 Answers3

2

Something processes can get locked. Try:
sudo /etc/init.d/apache stop
sudo pgrep apache
If the above command returns anything, do:
sudo pkill -9 apache
Then start apache again:
sudo /etc/init.d/apache2 start

James L
  • 6,025
  • 1
  • 22
  • 26
2

The child processes should stop as soon as they finish handling their current requests. Do you really want your server drop connections in the middle of serving a page? The restarted server will handle all new connections, as it has taken over listening for new connections.

Check after a minute or so to ensure that the children of the old server have died. If they are still running then you likely have a problem.

BillThor
  • 27,737
  • 3
  • 37
  • 69
  • I checked this and the process IDs do in fact change. I had assumed that they were not changing because the new processes seemed to be taking up about the same amount of RAM as the old processes. Do you know if there is a logical reason why Apache would be taking about the same amount of RAM as processes that have been killed? – Josh Pennington Aug 10 '10 at 23:19
  • @Josh If the service's workload hasn't changed dramatically since it was restarted, why *wouldn't* it require the same amount of RAM as before? – Skyhawk Aug 11 '10 at 00:08
  • Each process is using a lot more memory than I would have expected for a fresh process to take up. I would expect that each process take up a lot less memory than it did when I killed the process. – Josh Pennington Aug 11 '10 at 01:19
  • Unless you are loading something that builds and hangs onto memory structures as your run, the processes will use about the same amount of memory. Normally if the memory footprint is growing, it is a sign of a memory leak. The runner processes don't need to keep much in memory. Mostly they just read and send files with some possible filtering. This requires a few kilo bytes at most. – BillThor Aug 11 '10 at 20:02
1

PROCESS_APACHE=ps -ef | grep apache | awk {'print $2'}

kill -9 $PROCESS_APACHE

Rajesh
  • 21
  • 1