开发者

How to prevent emailed cron output

I'm using a cron that gets accesses a URL to run a scheduled process. I keep getting successful emails... is there a way for me to only get emails if the wget request fails?

开发者_C百科

wget http://www.domain.com/cron/dailyEmail 2>&1;


wget --quiet http://www.domain.com/cron/dailyEmail || echo "wget failed"

(Note that an empty response is not a failure.)


If you're running wget directly in the cron setup, then no. You can't conditionally redirect output. You could, however, put the wget command into a shell script, and do the conditionals there.

#!/bin/sh

OUTPUT=`wget .... 2>1`
if [ $? != 0 ]
   echo $OUTPUT
fi
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜