【问题标题】:curl error 56 (failure receiving network data) when run from cron从 cron 运行时出现 curl 错误 56(接收网络数据失败)
【发布时间】:2017-11-06 22:12:10
【问题描述】:

我有一个使用 curl 检索文件的 bash 脚本。当我从交互式 bash shell 运行它时它运行良好,但是当我使用 cron 运行脚本时 curl 失败并出现退出代码 56(接收网络数据失败)。我也收到一条错误消息

curl: (56) SSL read: errno -5961

有什么想法吗?

crontab 条目:

57 21 * * * /opt/tltutilities/lss/bin/get_hosts.sh 2>&1 | /bin/mail -s "get_hosts.sh" me@addr.edu

Bash 脚本:

#!  /bin/bash
BASEDIR=/opt/tltutilities/lss
cd $BASEDIR/bin
curl -v -o /opt/tltutilities/lss/tmp/etc_hosts https://remote_host.edu/pub/hosts/hosts
rc=$?
if [ $rc -ne 0 ]
then
  errmsg="curl: can't get hosts file: `grep \"^$rc \" curl_error_codes.txt`"
  echo $errmsg
  echo "$errmsg" | /bin/mail -s "get_hosts.sh failed with curl error $rc" me@addr.edu
fi

【问题讨论】:

    标签: bash curl cron


    【解决方案1】:

    需要定义/导出https_proxy环境变量,在cron提供的环境中没有设置。

    【讨论】:

      猜你喜欢
      • 2015-03-21
      • 2014-06-20
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 2022-08-02
      • 2018-10-09
      • 2022-11-04
      • 2022-06-16
      相关资源
      最近更新 更多