Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having a problem on my server when the PHP mail() function is being used in a browser, so through Apache.

When the script, lets call it mailtest.php, is being called through a browser, there is a 60 second delay in actually sending the message.

When I call php mailtest.php from the commandline, the mail is sent instantly, no delay.

After a restart of Apache, the delay is gone. However, it returns after a couple of hours.

I did an Strace and here you can see a delay of 30 seconds at the end.

13076 09:38:02 clone( <unfinished ...>
13076 09:38:32 <... clone resumed> child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xa5f346f8) = 13160

It's a virtual server btw running Debian.

Any ideas? I'm getting desperate.

share|improve this question
Have you tried running strace with -f? This should follow also the child processes (clone() and fork() create child processes). Maybe that'll shed some light on what's going on during those 30 seconds. – vstm Aug 27 '11 at 8:47
I did use the -f option. And once the clone is created, it runs fast. It looks like what Alex said could be the case. It takes 30 seconds to actually create the clone child process.... – Oscar Aug 27 '11 at 10:14
That's a real hum-dinger of a problem you've got there. Kudos for doing much better diagnostics than 99.9% of the people who ask questions here. – womble Aug 27 '11 at 22:07
I'm witnessing exactly the same problem in a PHP setup: sending e-mails takes 90s (strace shows that 2 intermediary processes are forked before we reach sendmail, so that's 30s per clone() syscall). But I'm not running Apache: I'm using nginx + php-fpm. It's in a LXC container running on an Ubuntu 10.04 LTS server which is an EC2 instance (Xen virtual machine). Other processes on the same machine (and same container) don't have any problem. – jpetazzo Jun 2 '12 at 6:40

clone(...) call is for creating child processes, so it looks like it took 30 seconds to create a new process in your system. Most probably RAM was exhausted and processes used swap extensively. Could you please check this using top and free? You can also monitor disk activity using iostat, probably there were lots of I/O operations.

share|improve this answer
Top was showing normal loads (between 0.5 and 2). If it happens again, I'll use iostat – Oscar Aug 27 '11 at 10:07
If clone were to take 30 seconds, all commands on the machine would be awfully slow (even a simple "ls" would take at least 30 seconds). I believe that the issue has nothing to do with RAM and swap. – jpetazzo Jun 2 '12 at 6:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.