LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-17-2001, 07:10 AM   #1
jamesyreid
LQ Newbie
 
Registered: Dec 2001
Posts: 3

Rep: Reputation: 0
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!
 
Old 12-17-2001, 11:21 AM   #2
speck
Member
 
Registered: Nov 2001
Location: US
Distribution: Slackware 14.2
Posts: 375

Rep: Reputation: 115Reputation: 115
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
 
Old 12-17-2001, 11:30 AM   #3
jamesyreid
LQ Newbie
 
Registered: Dec 2001
Posts: 3

Original Poster
Rep: Reputation: 0
Cron

Yes, some perl examples would be greatly appreciated!

Thanks in advance,

James
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Email Notification - Perl Script jamesyreid Programming 3 07-21-2009 08:56 AM
cron e-mail notification adm1329 Linux - Newbie 1 06-20-2004 08:27 PM
email notification mbegovic LQ Suggestions & Feedback 6 04-01-2004 01:36 PM
Suppress mail notification of cron event? jecoltrin Linux - General 2 02-02-2004 01:37 PM
email notification elainepearl Linux - General 1 01-14-2002 06:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:35 AM.

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
Open Source Consulting | Domain Registration