dongyi1921 2014-04-27 14:33
浏览 76

在后台执行PHP脚本

I have a table with ~500 rows, which will expand in the future.

In background.php I create some PDFs and send them email and FAXs to each record of this table: this requires a certain amounts of time, which means I can not do the operation on a browser window or with an AJAX call.

Now I'd like to create a background process (exec() or shell_exec() or proc_open() or ...?) which iterate throght the table and sends FAXs and mails.

I don't need logs because the script has an internal log system.

I've tried something like

<form method="post" action="">
  <input type="submit" name="background" value="go">
</form>

if(isset($_POST['background'])){
    exec('php /WEB/mysite/.../.../htdocs/test/background.php &') or echo 'Error';
}

where background.php is called from the user on the browser window!

I always get error but I don't know where and what error (probably errorS) I have!

I have no idea how to go forward...

EDIT Nobody on this site is able to answer my question properly? =(

  • 写回答

2条回答 默认 最新

  • dqm74406 2014-04-27 14:43
    关注

    For this and other similar tasks you can use cron job. It is time-based job sheduler in Unix-like operating systems. Webhosting companies usually provide this service for their clients.

    You just need to write the PHP script, set up time when it should be executed and after that it will run at specified time in background.

    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题