开发者

How to prevent emailed cron output

开发者 https://www.devze.com 2023-04-01 08:29 出处:网络
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百科

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

精彩评论

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