How to solve set_time_limit not affecting PHP-CLI?
#!/usr/bin/php -q 2 second
Could you try running your php via exec and use the "timeout" command? (http://packages.ubuntu.com/lucid/timeout)
usage: timeout [-signal] time command.