LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Script "email notification" (https://www.linuxquestions.org/questions/linux-newbie-8/script-email-notification-716474/)

romio 04-02-2009 08:49 PM

Script "email notification"
 
I need to have a script that does the following:

1. Receive an email notifying me that a file has been uploaded to my server
2. Date and Time of upload + the location of the file

i am asking this bcoz i notice that some one is able to upload a mail() file which has caused my server to crash, i just managed to clean my queue which contained 116720 files!!

i am not really sure how did that happened, but with the script above i can win some time in order to find the bug.


Thanks in advance.

maresmasb 04-02-2009 10:04 PM

The most common approach would be to check the log file.

The another approach is to install a cron job script that checks for differences in the file system. This can take long, if you want to check the entire file system.

Or just an additional function to your upload script (if the uploaded files have been done by one of your existing scripts) to write a log.

As a matter of fact, log writing makes more sense. In your example with the 116720 files that would mean to send you 116720 e-mails. Flooding your mail box is not a good idea.

billymayday 04-02-2009 10:44 PM

It's only one file uploaded that sent tons of emails, so by my calculation, one upload = one email.

Look into incrontab. It let's you monitor directories for changes (such as file creation), and you could use that quite simply to send you a message. Think crontab based on inode changes rather than time.

romio 04-03-2009 02:30 AM

Quote:

Originally Posted by maresmasb (Post 3496760)
The most common approach would be to check the log file.

The another approach is to install a cron job script that checks for differences in the file system. This can take long, if you want to check the entire file system.

Or just an additional function to your upload script (if the uploaded files have been done by one of your existing scripts) to write a log.

As a matter of fact, log writing makes more sense. In your example with the 116720 files that would mean to send you 116720 e-mails. Flooding your mail box is not a good idea.


not exactly, one upload file = tons of emails, basically i will be receiving one or two emails max

romio 04-03-2009 02:37 AM

1 Attachment(s)
Quote:

Originally Posted by billymayday (Post 3496780)
Look into incrontab. It let's you monitor directories for changes (such as file creation), and you could use that quite simply to send you a message. Think crontab based on inode changes rather than time.

would you be kind and explain how could i use the incrontab to monitor any uploaded file into my wwww folder?

i have attached a sample file that are being uploaded into my web directory.


Thanks in advance

billymayday 04-03-2009 02:41 AM

I'll send you here (http://linux.die.net/man/5/incrontab) for a start, but basically, incrontab allows you to monitor /var/www or any other directory for files created, modified, or whatever you want, an then to perform some action. In your case, tha action would be to send a mail message with the file name.


All times are GMT -5. The time now is 08:23 PM.