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
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?
We do this by editing the /etc/crontab file and reset the MAILTO variable. This will disable all the cron daemon emails.
You can set the output file name while downloading file with the curl, execute: $ curl -o file. pdf https://your-domain-name/long-file-name.pdf. Follow a 301-redirected file while downloading file with curl, run: $ curl -L -o file.
To schedule a curl command to run at 3am daily, you can insert the line: 0 3 * * * curl args... Notice how the minutes and hour correspond to 3am (side note: cron uses 24 hour time format, no am or pm). The asterisks that follow mean every day of month, every month, every day of week.
There are a few options here.
You can use the -s
or --silent
flag to silence all output. From the curl
manpage:
-s/--silent Silent or quiet mode. Don’t show progress meter or error mes- sages. Makes Curl mute.
Or, rather than using something like system
in your Perl script to run curl
, you could use backticks or the qx
operator to capture the output to a variable.
Or, you could open your curl
process with a pipe to capture its STDOUT and look at it later.
Finally, you might want to explore replacing your system calls to curl
with a native Perl library like LWP::UserAgent or Mechanize.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With