Got an email when run cron job for every 15 minutes of particular URL in Cent OS
I set cron job with every 15 minutes for particular URL in Cent OS. But, i did not return any email. i get an email with below contents when every 15 minutes runs the cron. How to avoid email notification.
Cron job for 15 min:
*/15 * * * * /usr/bin/curl http://domain.com/cronprocess 2>&1 >> /var/www/html/cron.log
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
0 0 0 0 0 0 开发者_如何学JAVA 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
The redirection operator 2>&1
needs to go after the redirection to the log file, if that's what you intended. There is also an option (-q
IIRC) to suppress the progress indicator from curl
.
*/15 * * * * /usr/bin/curl http://domain.com/cronprocess >>/var/www/html/cron.log 2>&1
or probably more likely
*/15 * * * * /usr/bin/curl -q http://domain.com/cronprocess >>/var/www/html/cron.log 2>&1
Edit: So to emphasize, you are setting up curl to output the fetched page to cron.log. I would not call it sane behavior to also append the error messages to that log file, but since you already had the 2>&1
there, I assume that's really what you want. The way you had it, it would do the redirections in the wrong order; it would redirect standard error to standard output, then redirect standard output to be appended to the file (but not standard error, which would remain connected to your original standard output).
精彩评论