设置一个“查找”命令cron / bash脚本,如果有任何结果,哪些电子邮件?

我想设置一个cron作业,例如每24小时检查一次,看是否有如下命令(检查恶意shell攻击脚本)的“find”命令是否有任何结果:

find /home/username/public_html -type f -print0 | xargs -0 egrep '(\/tmp\/cmd(temp)?|SnIpEr_SA|(c99|r57|php)shell|milw0rm)' 

如果有任何结果,我会收到一封电子邮件,如exam@ple.com。

也许某些情况下,调用bash脚本的cron作业每天运行一次,其中find命令通过bash脚本运行,bash脚本检查find命令返回的字符数,并在大于0时发送电子邮件不知道这是否是最好的方法,但这是我能想到的唯一方法。

我不知道bash编程是否足以实现这个(或者类似的select) – 这个实现是什么样的?

cron的默认动作是通过脚本输出给你发邮件只需编辑你的crontab(crontab -e)并在顶部添加MAILTO变量。

 MAILTO=exam@ple.com 30 1 * * * find /home/username/public_html -type f -print0 | xargs -0 egrep '(\/tmp\/cmd(temp)?|SnIpEr_SA|(c99|r57|php)shell|milw0rm)'