2013-04-15 39 views
1
我有一個小問題

發送結果,我正在和cron任務每5分鐘,這是尋找文字鏈,並沒有取代它.. 爲了租期,提高的東西我想一個新的功能添加到我的cronstrask:如果它取代的東西給我發電子郵件..如果crontask沒有找到鏈中沒有任何需要發送郵件。我不知道該怎麼做,也許你可以幫助我。 這裏是我當前的cron任務:查找和通過ssh替換 - 通過郵件

find /home -type f | xargs sed -i 's$chain if would like to era$ $g' 

在此先感謝

回答

0

這裏是我與其他永世的幫助下做了一個例子。 這將可能幫助一些其他永世

#!/bin/bash 
grep -r -q 'stringtoreplace' /home/  #Find the string in all files on my home 
if [ $? == 0 ] #if the last result fit then 
then 
     echo "At the following time : " $(date +%H:%M:%S) | mail -s "[Serveur Leaked] Bad iframe has been found " [email protected] #we send a mail with the date 
     find /home -type f | xargs sed -i 's$stringtoreplace$ $g' #we replace the string with a whitespace 
else 
     exit 1 
fi 
exit 0