如何从我的 cronjob 中防止 curl 输出的邮件? [英] How can I keep curl output out of mail from my cronjob?

查看:11
本文介绍了如何从我的 cronjob 中防止 curl 输出的邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 Perl 脚本,它作为每日 crontab 作业运行,通过 CURL 将文件上传到 Amazon S3.我希望将 cron 作业的输出通过电子邮件发送给我,这工作正常,但我不希望该电子邮件包含与 CURL 上传相关的消息(仅那些我的脚本正在输出的消息).以下是我现在在每日电子邮件中看到的与 CURL 相关的消息:

I have written a Perl script that runs as a daily crontab job that uploads files to Amazon S3 via CURL. I want the output of the cron job emailed to me which works fine but I don't want that email to include messages related to the CURL upload (only those message my script is outputting). Here are the CURL related messages I'm seeing in the daily email right now:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0  230M    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0  230M    0     0    0  544k      0  1519k  0:02:35 --:--:--  0:02:35 1807k
  0  230M    0     0    0 1744k      0  1286k  0:03:03  0:00:01  0:03:02 1342k
  1  230M    0     0    1 2880k      0  1219k  0:03:13  0:00:02  0:03:11 1250k
  1  230M    0     0    1 4016k      0  1198k  0:03:17  0:00:03  0:03:14 1218k
  2  230M    0     0    2 5168k      0  1186k  0:03:19  0:00:04  0:03:15 1202k
  2  230M    0     0    2 6336k      0  1181k  0:03:19  0:00:05  0:03:14 1157k
  3  230M    0     0    3 7488k      0  1177k  0:03:20  0:00:06  0:03:14 1147k
  3  230M    0     0    3 8592k      0  1167k  0:03:22  0:00:07  0:03:15 1142k
  4  230M    0     0    4 9744k      0  1166k  0:03:22  0:00:08  0:03:14 1145k
  4  230M    0     0    4 10.6M      0  1163k  0:03:23  0:00:09  0:03:14 1142k
  5  230M    0     0    5 11.7M      0  1161k  0:03:23  0:00:10  0:03:13 1140k
  5  230M    0     0    5 12.8M      0  1158k  0:03:23  0:00:11  0:03:12 1133k
  6  230M    0     0    6 13.9M      0  1155k  0:03:24  0:00:12  0:03:12 1138k
  6  230M    0     0    6 15.0M      0  1155k  0:03:24  0:00:13  0:03:11 1138k
  7  230M    0     0    7 16.1M      0  1152k  0:03:25  0:00:14  0:03:11 1131k
  7  230M    0     0    7 17.2M      0  1152k  0:03:25  0:00:15  0:03:10 1132k
  7  230M    0     0    7 18.4M      0  1152k  0:03:24  0:00:16  0:03:08 1140k

我正在使用一个简单的 Perl system() 调用来调用 CURL.有谁知道我可以提供什么命令行参数来关闭上传进度报告?

I am using a simple Perl system() call to invoke CURL. Does anyone know what command line argument I can supply CURL to turn off the reporting of the upload progress?

推荐答案

出于某种原因,我的 CURL 版本无法识别 -s 或 --silent,我知道这毫无意义.正如@Friedo 建议的那样,我尝试使用反引号或 qx 运算符,它们也没有摆脱不需要的上传进度报告.最终,我采用了将 >/dev/null 2>&1 添加到解决问题的系统调用末尾的非常不优雅的路线.

For some reason my version of CURL wasn't recognizing the -s or --silent which I know makes no sense. As @Friedo suggested I tried using backticks or the qx operator which also didn't get rid of unwanted upload progress reporting. Ultimately I went the very unelegant route of adding >/dev/null 2>&1 to the end of the system call which resolved the issue.

这篇关于如何从我的 cronjob 中防止 curl 输出的邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆