Email 查找&;通过ssh替换-通过邮件发送结果

Email 查找&;通过ssh替换-通过邮件发送结果,email,replace,cron,Email,Replace,Cron,我遇到了一个小问题,我每5分钟运行一次和cron任务,这是查找文本链并将其替换为空。。 为了优化某些内容,我想在cronstrask中添加一个新功能:如果它替换了某些内容,请向我发送电子邮件。。如果crontask没有找到链,则无需发送邮件。我不知道怎么做,也许你能帮我。 以下是我当前的cron任务: find /home -type f | xargs sed -i 's$chain if would like to era$ $g' 提前感谢这是我在其他人的帮助下做的一个例子。 它可能会帮

我遇到了一个小问题,我每5分钟运行一次和cron任务,这是查找文本链并将其替换为空。。 为了优化某些内容,我想在cronstrask中添加一个新功能:如果它替换了某些内容,请向我发送电子邮件。。如果crontask没有找到链,则无需发送邮件。我不知道怎么做,也许你能帮我。 以下是我当前的cron任务:

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

提前感谢

这是我在其他人的帮助下做的一个例子。 它可能会帮助其他人

#!/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 " my@mail #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