2011-11-17 120 views
0

調用我有以下頁面:example.com/test.html與內容:電子郵件內容時,通過cron

<b>hello world</b> 

我通過cron命令調用這個頁面:

/usr/bin/curl -LO http://example.com/test.html 

當cron作業執行並完成時,是否可以通過電子郵件向我發送頁面內容?在這個例子中,電子郵件的正文應該包含

<b>hello world</b> 

回答

0

也許你想創建一個shell腳本,下載網頁和電子郵件給你,就像這樣:

#!/bin/bash 
/usr/bin/curl -LO http://example.com/test.html 
cat test.html | mail -s "Put a subject here" [email protected] 

,然後調用這個腳本通過cron。

+1

你應該能夠切出test.html,並將curl輸出傳送給郵件:curl http://example.com/test.html | mail -s「主題」[email protected] –

+0

@PaulRubel按照我的意願工作,謝謝! – IMB

0

寫一個腳本,並從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