11

how can I do that?

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

Alex
  • 66,732
  • 177
  • 439
  • 641

2 Answers2

4

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/

niczak
  • 3,897
  • 11
  • 45
  • 65
4

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.

Tim Post
  • 33,371
  • 15
  • 110
  • 174