1. Register a shutdown function ref: http://php.net/manual/en/function.register-shutdown-function.php
  2. Call “get_included_files”
    ref: http://php.net/manual/en/function.get-included-files.php
  3. Save the returned file list to a log somewhere on your server.

This shouldn’t affect the response times – but be warned, it WILL generate higher disk I/O (which might in turn bottleneck at peak usage times).

Don’t let the size of the log file go up too much. Ensure crons/schedulers or any background processes use this shutdown function.

 

<?php
function shutdown()
{
 $xyzzy="";
 $included_files = get_included_files();
 foreach ($included_files as $filename) {
 $xyzzy .= "$filename\n";
 }
 file_put_contents($_SERVER['DOCUMENT_ROOT']."/shutdownlogger/incfiles.txt", $xyzzy, FILE_APPEND );
}

register_shutdown_function('shutdown');
?>

author image

About Chaitanya Dhareshwar

Chaitanya Dhareshwar, a Technocrat | CIO.

Member of various key technology and management organizations (IETF, ISOC, CSI)
with 14 years of technology management & advisory experience
has transformed companies from "stone age" to "space age". I build high-scale, self-sustaining, self-service platforms. Passionate about technology, innovation and creating killer opportunities that only great tech can bring. I've led teams from 5 - 150 people, and am hands-on with all forms of technology.

[BTEN id="33"]

You Might Also Like...

Word interop automation – the INCREDIBLY easy solution
Magento API giving issues with Unicommerce integration
Replacing Apache with NGINX on an AWS Linux server
BUT YOU’RE IN A FULL TIME JOB!! HOW CAN YOU LIVE WITH YOURSELF??