Alex
Alex

Reputation: 68070

how to monitor the CPU usage of a PHP script

how can I do that?

how do share hosts limit the CPU time for a script?

Upvotes: 11

Views: 15494

Answers (2)

user50049
user50049

Reputation:

Web hosts have several means of limiting PHP (and how much memory a child web server process can consume). Commonly, PHP is limited by the max execution time configured in php.ini (which is also set so that functions like set_time_limit() can't override it. Additionally, hosts use things ulimit to limit the amount of memory / time that any given process can consume.

If not configured to restrict PHP to individual webroots, you can open /proc/self and have access to statistics about your process. Note, you won't be able to do that, or use phpsysinfo if open_basedir is in effect.

Upvotes: 4

niczak
niczak

Reputation: 3917

There isn't a native method for doing this in PHP so I would try phpSysInfo as it provides information on CPU, uptime, ethernet, SCSI, IDE, etc. http://phpsysinfo.sourceforge.net/

Upvotes: 4

Related Questions