调用我有以下页面:example.com/test.html与内容:电子邮件内容时,通过cron
<b>hello world</b>
我通过cron命令调用这个页面:
/usr/bin/curl -LO http://example.com/test.html
当cron作业执行并完成时,是否可以通过电子邮件向我发送页面内容?在这个例子中,电子邮件的正文应该包含
<b>hello world</b>
调用我有以下页面:example.com/test.html与内容:电子邮件内容时,通过cron
<b>hello world</b>
我通过cron命令调用这个页面:
/usr/bin/curl -LO http://example.com/test.html
当cron作业执行并完成时,是否可以通过电子邮件向我发送页面内容?在这个例子中,电子邮件的正文应该包含
<b>hello world</b>
也许你想创建一个shell脚本,下载网页和电子邮件给你,就像这样:
#!/bin/bash
/usr/bin/curl -LO http://example.com/test.html
cat test.html | mail -s "Put a subject here" [email protected]
,然后调用这个脚本通过cron。
写一个脚本,并从cron调用它,假设一个“/ home /我的帐户”是您的家庭帐户和 “[email protected]”是你的电子邮件和“网页”是你的主题尝试以下
#!/bin/sh
mkdir /home/myaccount/mywebdir
cd /home/myaccount/mywebdir
rm test.html
/usr/bin/curl -LO http://example.com/test.html
if [ -e test.html ]
then
cat test.html | mail -s "webpage" [email protected]
fi
你应该能够切出test.html,并将curl输出传送给邮件:curl http://example.com/test.html | mail -s“主题”[email protected] –
@PaulRubel按照我的意愿工作,谢谢! – IMB