I can't say it's the reason for your problems, but it's certainly not necessary to call your scripts tha way. I never call php with the -f switch, none of my scripts have a shebang, and run like this:
/usr/local/bin/php -q /home/me/script/foo.php
An exception are some that I use as UNIX utilities; they do have the shebang, are in my $PATH, have execute permissions, and I call them simply by name. For example, my PPP link at home goes for days on end with no problems then bites the dust repeatedly for a day or two, (must be running Windoze ppp servers) and after a while, fetchmail gives up the fight. So, "refetch" gives me this:
#!/usr/local/bin/php -q
<?php
$foo=shell_exec("ps -ax | grep fetchmail");
$bar=explode("\n", $foo); // "grep fetchmail" is also caught by ps(1)
$baz=strtok($bar[0], " ");
$killstring="kill -USR1 $baz";
system($killstring);
?>
Dunno if this is helpful, but here 'tis....