做了一些实验用exec和shell_exec我已经揭露了完美工作的解决方案!我选择使用,shell_exec所以我可以记录发生(或不发生)的每个通知过程。(shell_exec以字符串形式返回,这比使用更容易exec,将输出分配给变量,然后打开要写入的文件。)
我正在使用以下行来调用电子邮件脚本:
shell_exec("/path/to/php /path/to/send_notifications.php '".$post_id."' 'alert' >> /path/to/alert_log/paging.log &");
注意&命令的结尾很重要(正如@netcoder所指出的那样)。此UNIX命令在后台运行进程。
在脚本路径之后用单引号括起来的额外变量被设置为$_SERVER['argv']我可以在我的脚本中调用的变量。
然后,电子邮件脚本使用输出到我的日志文件>>,并将输出如下内容:
[2011-01-07 11:01:26] Alert Notifications Sent for http://alerts.illinoisstate.edu/2049 (SCRIPT: 38.71 seconds)
[2011-01-07 11:01:34] CRITICAL ERROR: Alert Notifications NOT sent for http://alerts.illinoisstate.edu/2049 (SCRIPT: 23.12 seconds)