php - Cronjob wget 在不可预知的时间间隔内多次触发 http 请求
问题描述
我使用 wget 在 ubuntu 服务器中为 php 服务设置了 crons,并且每 5 分钟运行一次 crons。这几天效果很好。最近,我遇到了一个问题,即服务运行了两次或三次(根据应用程序日志的输出),但 cron 只运行了一次(根据 syslog)。
我已经完成了链接为什么这个 cron 条目执行了两次?但这对我不起作用。我只有一个 PID(ps -aux | grep 'cron'),我重新启动、停止、启动了 cron 服务(service cron restart/stop/start),但它们都不适合我。所以最后我重新启动了服务器,因为 cron 作业是 init 服务,但在重新启动后,我也遇到了同样的问题。
cron 以 root 用户身份运行。
克朗:
*/5 * * * * /usr/bin/wget --no-check-certificate https://**********/controlller/method
从系统日志:
Jul 31 12:05:01 web-server CRON[26997]: (root) CMD (/usr/bin/wget --no-check-certificate https://xx.xx.xx.xx/controller/method)
Jul 31 12:10:01 web-server CRON[27222]: (root) CMD (/usr/bin/wget --no-check-certificate https://xx.xx.xx.xx/controller/method)
Jul 31 12:15:01 web-server CRON[27470]: (root) CMD (/usr/bin/wget --no-check-certificate https://xx.xx.xx.xx/controller/method)
Jul 31 12:20:01 web-server CRON[27768]: (root) CMD (/usr/bin/wget --no-check-certificate https://xx.xx.xx.xx/controller/method)
ps -aux | grep 'cron'
root 1079 0.0 0.0 26012 696 ? Ss Jul30 0:03 cron
从应用程序日志:
31 Jul 2019 12:05:01 [26836] DEBUG [xx.xx.xx.xx]:entered into controller/method
31 Jul 2019 12:05:01 [26922] DEBUG [xx.xx.xx.xx]:entered into controller/method
31 Jul 2019 12:13:00 [27378] DEBUG [xx.xx.xx.xx]:entered into controller/method
31 Jul 2019 12:13:01 [27376] DEBUG [xx.xx.xx.xx]:entered into controller/method
31 Jul 2019 12:23:47 [27733] DEBUG [xx.xx.xx.xx]:entered into controller/method
31 Jul 2019 12:23:47 [27674] DEBUG [xx.xx.xx.xx]:entered into controller/method
从 Apache2 访问日志:
xx.xx.xx.xx - - [31/Jul/2019:12:05:01 +0200] "GET /controller/method HTTP/1.1" 200 6914 "-" "Wget/1.15 (linux-gnu)"
xx.xx.xx.xx - - [31/Jul/2019:12:05:01 +0200] "GET /controller/method HTTP/1.1" 200 6909 "-" "Wget/1.15 (linux-gnu)"
xx.xx.xx.xx - - [31/Jul/2019:12:13:01 +0200] "GET /controller/method HTTP/1.1" 200 6862 "-" "Wget/1.15 (linux-gnu)"
xx.xx.xx.xx - - [31/Jul/2019:12:13:00 +0200] "GET /controller/method HTTP/1.1" 200 6862 "-" "Wget/1.15 (linux-gnu)"
xx.xx.xx.xx - - [31/Jul/2019:12:23:47 +0200] "GET /controller/method HTTP/1.1" 200 6862 "-" "Wget/1.15 (linux-gnu)"
xx.xx.xx.xx - - [31/Jul/2019:12:23:47 +0200] "GET /controller/method HTTP/1.1" 200 6862 "-" "Wget/1.15 (linux-gnu)"
解决方案
推荐阅读
- r - 如何查找值是否与上一行不同并在下一行重复该信息(如循环)?
- node.js - 使用独立 API 保护单页应用程序免受 XSRF 影响
- python - 如何在 Python (BeaufitulSoup) 中在 CSV 中为多网址刮板附加新行?
- coffeescript - tex 文件的原子片段
- cartopy - Mac OS 上的 Cartopy 安装:Python 3.8 和 Matplotlib 3.3.3
- python-3.8 - TypeError:需要一个整数(获取类型 str)Python
- laravel - 防止用户在 Ubuntu 中运行 PHP artisan 命令
- google-cloud-firestore - firebase 规则应该如何在收集数据中找到并检查是否存在?
- android - KMM 与 iOS Arm64 二进制框架 (.xcframework) 和 cinterop
- binary - 0和-0的符号幅度相加?