带wget的crontab-为什么它运行两次? [英] crontab with wget - why is it running twice?
问题描述
我有一个从Web服务运行并插入到数据库的php脚本。
I've a php script which runs from webservice and insert to DB.
crontab -e
crontab -e
......other cron tasks above.......
...
..
..
# Run test script.php at 1610
10 16 * * * /usr/bin/wget -q -O /home/username/my_cronjobs/logs/cron_adhoc http://localhost/project/script.php
显然,在16:10,此脚本运行了两次!
16:10:01和16:25:02
Apparently, at 16:10, this script is run twice! 16:10:01 and 16:25:02
这是错误的事情,必须使用wget吗??
还是我在cron作业上设置了错误的时间表?
Is it something wrong and gotta do with using wget?? Or did i set the schedule on cron job wrongly?
当我运行来自浏览器的http://localhost/project/script.php ,它只会运行一次。.
When i run http://localhost/project/script.php from browser, it will only run once..
关于此的任何想法问题?
Any idea regarding this problem ?
我已经测试过,没有其他用户运行相同的工作...我怀疑wget的工作方式。
I've tested, there are no other users running the same job... I suspect the way wget works.
由于我的脚本至少需要20分钟才能完成而不发送回响应(它正在从Web服务中提取大量数据并保存到db)..怀疑默认情况下超时或重试wget会导致此问题。
As my script needs at least 20mins to complete without sending back a response (it is pulling alot of data from webservicces and save to db) .. suspect there's a time out or retry of wget by default causing this problem.
推荐答案
我认为我已经解决了自己的问题。
i think i solve my own question.
我的php需要一些时间来加载,我猜wget重试或在默认的指定时间后超时。
My php takes some time to load, i guess wget retries or time out after some default specified time.
我使用/ usr / bin / php
I solved it by using /usr/bin/php
这篇关于带wget的crontab-为什么它运行两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!