dtyw10299 2017-12-05 17:00
浏览 64
已采纳

PHP Cron Manager脚本停止页面加载

I'm trying to make a script that schedules a cron job that sends e-mails on a specific date. I followed this tutorial for making a php cron manager, and it loaded with no problem. But when I tried to make a SSH connection with the script just to see if it would raise any errors, the page stops loading where I place the code, no errors are shown and no error_log file is created anywhere, I really don't understand why the page stops loading.

$crontab = new Ssh2_crontab_manager('xxxxxxxxxxx.xxx', '22', 'xxxxxxx', 'xxxxxxxxxxx');

I only expect it to connect and continue the page or that it at least give me an error that I can search for the solution

Nothing, just a page that's partially loaded and no error, it just stops there.

  • 写回答

1条回答 默认 最新

  • dongyan1841 2017-12-05 21:24
    关注

    Your approach above totally over complicates what you are trying to do. You have a php script you want to run at certain intervals throughout the day, sending a few emails each time to people in your database.

    Obviously I have no idea what your database looks like, but here's a basic concept.

    • Add a column to your email addresses database called sent with default value set to 0
    • Write your php script and in your database query use LIMIT = 10 or whatever to only retrieve a few email addresses each time it runs, use WHERE sent = 0 to only retrieve email addresses you havent sent to yet
    • Then UPDATE each row to SET sent = 1 after the script has run to mark those users as having already been emailed. Include some conditional code so that if there are no more email addresses for that day WHERE sent = 0 then script just exits.

    • Create a cron job to run at your chosen interval which runs your php script and just leave it.

    There is no need to delete the cron job, if there are no emails to send it will just run briefly and quit. The whole point of cron jobs is to automate repetitive tasks, you set once and forget. The filters are flexible enough to give you a lot of control over when they run.

    For example 0 9-17/2 * * 1-5 php /path/to/script.php would run a script every other hour between 0900 and 1700, Monday to Friday

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?