Why so many gettimeofday calls?

Gettimeofday is mostly called by Apache to log entries in debug-files. Also some modules use gettimeofday. So nothing to worry about.

EDIT: I did some php source code digging and came up with the following results: Most time related php functions will use the system time. Since they use the system time, gettimeofday will be called a lot so if you want to reducte the calls, reducte your time related functions.

I have to remark though that other functions also make gettimeofday-calls. For example if you use php_session_start, this will (sometimes, depening on a few parameters like if a new session,...) make a call to php_combined_lcg which will make in his turn a call to lcg_seed if there is no seed value set to get a pseudo random number. And lcg_seed will make a gettimeofday call. Keep this in mind.


I have discovered that having the php module, xdebug, enabled causes strace to report several gettimeofday calls.


Every process that requires a timestamp calls gettimeofday, so it is difficult to know whether it is normal or not.

For example, It can be a module that creates a log, a module that checks the time... In fact, in your case, to know why there are so many gettimeofday, disable apache modules that could be responsible for calling gettimeofday. There are maybe too many writes to numerous log files located in different folders.

  • Disable the usual suspects like mod_log_debug or mod_status
  • Reload configuration of Apache
  • strace