LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-02-2009, 09:49 PM   #1
romio
LQ Newbie
 
Registered: Mar 2009
Posts: 10

Rep: Reputation: 0
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.
 
Old 04-02-2009, 11:04 PM   #2
maresmasb
Member
 
Registered: Apr 2009
Posts: 108

Rep: Reputation: 24
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.

Last edited by Tinkster; 10-30-2010 at 04:30 PM.
 
Old 04-02-2009, 11:44 PM   #3
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
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.
 
Old 04-03-2009, 03:30 AM   #4
romio
LQ Newbie
 
Registered: Mar 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by maresmasb View Post
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
 
Old 04-03-2009, 03:37 AM   #5
romio
LQ Newbie
 
Registered: Mar 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by billymayday View Post
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
Attached Files
File Type: txt file.txt (2.1 KB, 2 views)
 
Old 04-03-2009, 03:41 AM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
Simple "Email Alert" Script/Solution zok Linux - Networking 7 07-09-2008 02:13 PM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 08:42 AM
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 10:00 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 03:32 PM


All times are GMT -5. The time now is 09:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration