1

I have a cron job that executes once per day:

0 20 * * * /usr/bin/wget --timeout=10800 -O /home/File.txt http://www.site.com/script.php

and so far all was fine, but recently I found out the script just stops.

I looked in the /var/log/httpd/error_log (it's a CentOS) and found this:

[Thu Nov 21 21:30:32 2012] [notice] child pid 8985 exit signal Segmentation fault (11)

Now, this means two things: the script was successfully running for about hour and a half, but then the segmentation fault happened. Ususally the script takes around 2 hours to complete, so it lacks around half an hour to complete it's job.

Now, I can't find the error which causes the script to stop even though I do have error_reporting turned on.

I'm wondering, is there some way so that I can find a potential error line which caused the script to terminate?

I did try google, and SO, ofc, and tried to achieve the same as on this question here on SO by doing this:

0 20 * * * /usr/bin/wget --timeout=10800 -O /home/File.txt http://www.site.com/script.php 2>1& >> /home/log.txt

but the log file is empty. I'm not so good at managing linux so it may be that my command is wrong in this cronjob, so please steer me right.

4

2 回答 2

2

尝试这个

0 20 * * * /usr/bin/wget --timeout=10800 \
-O /home/File.txt http://www.site.com/script.php  >> /home/log.txt 2>&1 

2>&1 部分告诉将 STDERR 发送到与 STDOUT 相同的位置。

于 2012-11-22T14:58:38.853 回答
0

Cron 将命令的输出发送到正在执行它的用户的电子邮件中。

要使该系统正常工作,您必须安装邮件守护程序,例如 exim 或 postfix。

此外,您要求 wget 在 /home/ 目录中写入文件,我认为是非 root 用户,这意味着您不能这样做。如果你是 root 你不应该那样做。

于 2012-11-22T15:10:24.360 回答