LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Cron Email Notification(?) (https://www.linuxquestions.org/questions/linux-general-1/cron-email-notification-10206/)

jamesyreid 12-17-2001 06:10 AM

Cron Email Notification(?)
 
Hi,

I have a problem relating to a cron task that I am trying to schedule, and I'd be grateful if someone could shed some light on it...

I have added a new user to my Linux webserver, and when they login they can then upload files to their home directory using Secure Shell. I have then scheduled a cron job to run every hour which will copy the reports from the user's home directory to the relevant areas of our website (so that the reports appear online).

With me so far?

This all works fine, however the user has asked me if it is possible to setup some sort of email notification, whereby an email alert will be sent to an external email address whenever a report they have uploaded is copied across to the website. It's basically to let one of our customers know every time there is a new report available for viewing online.

Probably another cron job is the most obvious solution, but I'm afraid I don't know where to start. Is it possible to set-up auto email notification using cron?

Any assistance would be gratefully received!

speck 12-17-2001 10:21 AM

You should put the copying of the files to the webserver in a script (perl, shell, etc.) and execute that script in the cron. It's then pretty trivial to test if the file exists and send a notification if true. A basic shell example would be:

#! /bin/sh

if [ -s newfile.html ]
then
cp newfile.html /newpath/newfile.html
mail -s "New file for you" joe@aol.com
fi


If there are multiple files and they can have any name, I would suggest coding the script in perl. That's a bit more complicated, but not hard at all. If you need it, I can post examples of that as well.

Speck

jamesyreid 12-17-2001 10:30 AM

Cron
 
Yes, some perl examples would be greatly appreciated!

Thanks in advance,

James


All times are GMT -5. The time now is 12:18 AM.