- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个 PHP cron 作业在运行 29 分钟后失败。日志中的错误 (/var/log/php_errors.log
) 是:
[01-Mar-2012 00:32:57 UTC] PHP Fatal error: Maximum execution time of 60 seconds exceeded in /path/file.php on line 2079
触发 cron 的 crontab 条目是:
00 00 * * * /usr/bin/php /path/file.php
根据我的研究,我认为这与 max_execution_time
配置设置无关,因为:
问:为什么脚本提前终止?
注意事项:
脚本非常繁重,确实运行了数千个数据库查询,但我运行的是 top
,CPU 负载并不高。
错误日志中的行是 mysql_query
调用:
$sql = "SELECT SUM(amount) FROM mytab WHERE mem = '$id' AND validto > '$now'";
$res = mysql_query($sql);
> php -v
PHP 5.3.10 (cli) (built: Feb 2 2012 17:34:38)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH
> cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.7 (Tikanga)
更新 - 我发现了为什么脚本可以实时运行 29 分钟,但 PHP 可以退出引用执行时间更短。
Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.
(来自 the set_time_limit() docs ,但也在 the max-execution-time docs 中提到)。这对我来说很重要,因为大部分脚本都是长时间运行的数据库查询和支付 API 调用,它们不会增加执行时间。
最佳答案
好吧,你可以为时间限制设置一个更大的值,或者你可以使用 set-time-limit() 设置它为无限。 :
<?php set_time_limit(0); ?>
但实际上我也在脚本的开头使用了它
ignore_user_abort(1);
关于PHP cron 作业由于最大执行时间 fatal error 而提前终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9512413/
如果这有点含糊,我提前道歉,但我什至缺乏如何处理这个问题的基本想法 - 甚至不知道是否有合适的术语可供搜索。 我正在尝试编写一个按时间顺序排列的动画事件的表格驱动系统,其中描述性评论也从表格中提取出来
我是一个老狗,30 年前就用过 BASIC >。我以前在 python 中使用 for 循环时遇到过这种情况,但我选择这个例子是因为我担心循环: 我想解析一个长字符串,其中包含用逗号分隔的双引号中的单
我需要获取从当天算起的 5 个工作日的数组。 今天是:06/04/2018 我需要的输出是: { 0: 06/01/2018, //fri. 1: 05/31/2018, //th
我习惯于使用时间戳,我现在将尝试使用正常日期 2011-02-02 12:00:00 格式 我有这个: SELECT * FROM users_calenders WHERE date ? 我想选择日
我在我的本地仓库 (test-branch) 中创建了一个测试分支,并将其推送到 Github。 如果我转到我的 Github 帐户并选择这个 test-branch 它会显示信息: This bra
我正在尝试设置 JSON 对象的结束日期。结束日期等于开始日期后 30 天。有时这会返回正确的日期,有时则不会。 这是GetDateSchedulerFormatted函数 GetDateSchedu
我有一个执行器服务,它定期执行一堆任务。它们在启动时初始化并经常运行,到目前为止一切顺利。 我现在想添加功能来根据事件快速启动这些任务的执行。 我找到了decorateTask方法,它允许我存储我安排
我需要比当前日期提前 3 周的日期。并将所有日期添加到数组中。我怎样才能得到这个? let date = NSDate() let calendar = NSCalendar(cal
我正在使用以下代码设置日期对象: NSDate *date = [NSDate date]; NSCalendar *gregorian = [[NSCalendar alloc] i
我正在将字符串“Jun 11, 2012 9:30 PM”转换为 NSDate,并且由于某种原因我一直提前 4 小时。有趣的是,我正在使用相同的字符串在详细 View 中提供 UIDatePicker
我的理解是 Xamarin 的提前 (AOT) 编译器将 Xamarin.iOS 应用程序直接编译为 native ARM 汇编代码 (How Xamarin works) . 然而,我不明白的是为什
Angular 2 带有称为提前 (AoT) 的新功能。但是看了一番,还是不能真正理解。它是如何工作的?它将如何带来更好的性能?它与 JIT 有何不同? 谢谢。 最佳答案 Angular 在模块、指令
我看到了一些关于如何纠正这个问题的答案。我有一个 DateTime 类型的对象。我已分配该对象,如下所示。 obj.TimeStamp = DateTime.UtcNow; 我似乎找不到正确的组合或代
我是 Fortran 新手,我不明白这一行: write(*,'(a35)', advance='no') 在: program democonvertion implicit none
我一直在寻找如何做一些像 facebook 新闻提要这样的“高级”列表,但我认为我没有使用正确的关键字来搜索如何做到这一点。我对 android 环境还是很陌生。 这就是我要实现的目标: 我怎样才能得
我有一个包含 2 列的 pandas Dataframe。其中一个是日期格式的索引,另一个是比率 R(0 到 1 之间的数字)。如何向 pandas Dataframe 添加另一列,其中包含一天前一周
我有 2 个媒体查询大小 - only screen and (min-width: 980px)and (max-width: 1499px)"; only screen and (min-widt
我发现了这个: Is AOT (ahead of time) compilation available (or planned) in mono for android? 但是这个问题很老了。 在单
在我看来,当我调用 JTree.expandPath( path ) 默认情况下,它的所有父级也会展开。但我真正想做的是,设置特定的隐形 child 提前展开。这样当一个节点展开时,它的完整子树就会弹
我的时差显示不正确的输出,我正在尝试计算 startTime 和 endTime 之间的时差。 Date time1, time2; long difference; Simp
我是一名优秀的程序员,十分优秀!