开发者

crontab with wget - why is it running twice?

I've a php script which runs from webservice and insert to DB.

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/scri开发者_Python百科pt.php

Apparently, at 16:10, this script is run twice! 16:10:01 and 16:25:02

Is it something wrong and gotta do with using wget?? Or did i set the schedule on cron job wrongly?

When i run http://localhost/project/script.php from browser, it will only run once..

Any idea regarding this problem ?

I've tested, there are no other users running the same job... I suspect the way wget works.

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.


The wget docs give a default read-timeout of 900 seconds, or 15 minutes.

if, at any point in the download, no data is received for more than the specified number of seconds, reading fails and the download is restarted

This is why you were seeing the file called again 15 minutes later. You can specify a longer read-timeout by adding the parameter and an appropriate number of seconds:

--read-timeout=1800


i think i solve my own question.

My php takes some time to load, i guess wget retries or time out after some default specified time.

I solved it by using /usr/bin/php


Whose user's crontab is this?

Check if there is another user for which you set up cron job at different time and forgot about it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜