Script for checking files for last hour and send a mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for checking files for last hour and send a mail
# 1  
Old 11-14-2012
Script for checking files for last hour and send a mail

Hello,

I need to write a script to check the files in one folder , if that folder doesn't have files generated from last 1 hr then we need to send mail to particular persons.

So Can you please help me to write script to check the files and send email.

Thank you..
# 2  
Old 11-14-2012
You can make this as safe as you want, but as a quick one liner:

Code:
if [ `find ~/Temp -mmin -60 | wc -l` -eq 0 ]; then echo "0 files found in ~/Temp!" | mail -s "ERROR: Something bad" admin@abc.com; fi

or cleaned up:
Code:
if [ `find ~/Temp -mmin -60 | wc -l` -eq 0 ]; then
   echo "Blah blah mail" | mail ....
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove files send through mail

I wan't to remove last 5 and 10 days files from two directory and send the remove files list in mail Output send through mail find /kalia/cd/ -type f -mtime +5 exec rm {} \; find /kalia/uk/ -type f -mtome +10 exec rm {} \; Output send through mail File has been deleted ... (1 Reply)
Discussion started by: Kalia
1 Replies

2. Shell Programming and Scripting

Script that gathers specific values from files and puts it into HTML to send e-mail

Hi All, Sorry for long topic here. So the drill goes like that, I need a script which gathers different values from different files/locations. A_CT=`cat a.dat | awk -F'|' '{print $1}' >> report.txt` B_CT=`cat b.dat | awk -F'|' '{print $3}' >> report.txt` C_CT=`cat c.dat | awk -F'|'... (4 Replies)
Discussion started by: shivakid
4 Replies

3. Shell Programming and Scripting

Bash for checking and copy Daily files and send an email

Hello, Trying to get a bash for files received on daily basis and want to copy those files to different directory and send an email notification if file exists then send the file counts else Alert with no file received. FileName format: DailyTransaction_2015-03-09_ 200.csv before 200 their is... (1 Reply)
Discussion started by: krux_rap
1 Replies

4. Shell Programming and Scripting

Run the script continously but mail once in 1 hour

Hi, I have a script written for monitoring the queue manager status continously. below is the script. QMGR=`dspmq | awk '{print $1}' | cut -f2 -d "(" | cut -f1 -d ")"` QMSTATUS=`dspmq | awk '{print $2}' | cut -f2 -d "(" | cut -f1 -d ")"` count=`dspmq | awk '{print $1}' | cut -f2 -d "(" | ... (5 Replies)
Discussion started by: Anusha M
5 Replies

5. UNIX for Advanced & Expert Users

Zip the files if count is more than 0 and send a mail

All, I am new to shell scripting and trying to get the count of files that starts with error and with extension .out, if the count is greater than 0 and zip the file and send an email with the content of error.out file, here is my script cd /temp testcount =$('find . -name '*.out' -print |... (4 Replies)
Discussion started by: luckydoll
4 Replies

6. Shell Programming and Scripting

want to send 4 files output in one mail

Hi All , i have a wrapper HTML script -FS_CHECK_HTML_SCIPT_WT_Statusbar.sh which read a TXT file (script_KB.txt) and sends output to a mail in tabular format. TXT file is having 6 columns and so wrapper script create a table with 6 columns and supplies those 6 columns data from TXT file .... (2 Replies)
Discussion started by: deepakiniimt
2 Replies

7. Shell Programming and Scripting

How to send mail with multiple files attached?

Hi, I would like to send a mail with multiples files attached. Until now i was doing a "find" and then a "tar" of the text files. As I need to be able to read them on a mobile device such as Blackberry for instance, i would like to send them in one single mail, but without taring them. is... (2 Replies)
Discussion started by: Pierrito
2 Replies

8. AIX

Send mail with attachment having csv files

Hi, Could anyone please help me to send multiple files of .csv format in one mail. Thanks Aj (2 Replies)
Discussion started by: atinjain05
2 Replies

9. UNIX for Advanced & Expert Users

send all mail to files instead of relaying out

I had a wierd request from one of our guys. We are running on RedHat EL5. He asked that all mail originating from 3 servers he owns be sent to files instead of being sent out. My first thought is to set "Smart" relay host in sendmail.cf on each of the 3 servers so all messages are sent to a 4th... (0 Replies)
Discussion started by: mglenney
0 Replies

10. Shell Programming and Scripting

Script needed which will send a mail with attachment files

Hello, I need a shell script which need to send a mail with 4 *.csv files as attachments.Anybody can help me? At present i have a script which is sending only one file as attachments.But i need a script which send 4 files in a shot. #!/bin/ksh /bin/mail xxxx@xx.xom << EOF Subject:... (4 Replies)
Discussion started by: Mar1006
4 Replies
Login or Register to Ask a Question