如果修改了文件夹,如何发送电子邮件警报

时间:2015-04-16 10:41:04

标签: email inotify mutt

如果某个文件夹被修改,我想收到一封电子邮件提醒,但如何管理命令的输出,以便它发送一封电子邮件,而不只是显示终端中文件夹的更改?

类似以下内容但......在电子邮件部分中出现错误

inotifywait -m /home/tom -e create -e moved_to |
    while read path action file; do
        echo "The file '$file' appeared in directory '$path' via '$action'"
        | /usr/bin/Mail -s "notify" "email@12345mail.com"
    done

1 个答案:

答案 0 :(得分:2)

你可能只是错过done之前的分号吗?

此行适用于我(注意我还使用mutt代替Mail):

inotifywait -m /home/tom -e create -e moved_to | while read path action file; do echo "The file '$file' appeared in directory '$path' via '$action'" | /usr/bin/mutt -s "notify" "email@12345.com" ;done