[eluser]Dam1an[/eluser]
If you want this to happen at the end of every request, you could use a post system hook, or if using PHP5, you could put a __destruct function in MY_Controller
You can just execute the function by including it (if it's written as a class, you will need to add some code to instantiate the class)
You can use the APPPATH constant to build the include path