Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending mail from incrond

Tags:

inotify

I would like to monitor my /etc folder (ubuntu 12.04 lts) for changes with incrond and I would like send the result in e-mail with the following command:

/etc IN_ATTRIB,IN_CREATE,IN_DELETE,IN_MODIFY,IN_MOVED_FROM,IN_MOVED_TO /usr/bin/mail -s "ALERT:in etc: $@/$#" [email protected] < /dev/null

But the e-mail doesnt come...

What is the matter?

Thanks for yor help.

like image 778
Tamás Varga Avatar asked Oct 25 '25 02:10

Tamás Varga


1 Answers

I had similar troubles when I first tried using incron. The trick is that when the documentation says use command "abc $@/$#" it means exactly that. You will need to create a small shell script that takes the returned value from incrond and sends the appropriate mail message.

So the incrontab entry should look like this:

/etc IN_ATTRIB,IN_CREATE,IN_DELETE,IN_MODIFY,IN_MOVED_FROM,IN_MOVED_TO /usr/local/bin/mail_command.sh $@/$#

with mail_command.sh taking the given argument and processing as appropriate.

Matthew

like image 127
Matthew Wild Avatar answered Oct 27 '25 00:10

Matthew Wild