简体   繁体   中英

cron daemon with curl command is sending empty emails

my cron daemon is sending empty emails after job execution.

This is the cron job

curl -m 900 --connect-timeout 900 -s 'http://example.com/job.php' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36' --compressed -o ~/cronlog && mailx -s "example.com cron job executed" myemail@gmail.com < ~/cronlog

I receive emails but they are empty.

If I execute the above command from terminal the content of ~/cronlog is in the email.

Job is executed as current user, so "~" should be set.

Do you have access to crontab?

If so, i'd use the cron scheduler to email yourself. It will email anything the script outputs.

Under crontab, or /etc/cron.d/local:

MAILTO=example@mail.com

* * * * * your/cron/path

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM