The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need shell script to get last 10 char from a file name and write in to a new file raj0390 Shell Programming and Scripting 2 07-28-2008 04:09 AM
Need to write a script in UNIX to find a file if another file exists mmdawg Shell Programming and Scripting 1 05-04-2008 07:40 PM
PHP Script that sends mail - Postfix breaks it boopfm523 Shell Programming and Scripting 0 03-05-2008 08:38 PM
How to write a shell script to send an email to an id madhumathikv Shell Programming and Scripting 4 10-23-2007 02:19 PM
Email message if file size > 0 bytes poste_d_ordure Shell Programming and Scripting 1 06-02-2006 04:02 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-12-2008
Registered User
 

Join Date: Aug 2008
Posts: 22
write the script to get the file size and sends an email

hi all
Anybody have an idea to write the script to get the file size and sends an email when file size increse more than 10mb. thanks
Reply With Quote
Forum Sponsor
  #2  
Old 08-12-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,264
Code:
/bin/find /path/tofile -name filename.whatever  -size +10485760c > ./big.dat
if [[ -s ./big.dat ]] ; then
     big.dat > /usr/bin/mailx -s 'file too big '  usename@foo.com
fi
You have to enter this into cron to run, say, every five minutes. If you want it checking constantly.
Reply With Quote
  #3  
Old 08-12-2008
Registered User
 

Join Date: Aug 2008
Posts: 22
Thanks for your reply..
i have something which i didnt get..

/bin/find /path/tofile -name filename.whatever -size +10485760c > ./big.dat

i have several files (*.txt) under the /var/opt/abc, then also is this command work?
Reply With Quote
  #4  
Old 08-12-2008
Registered User
 

Join Date: Aug 2008
Posts: 22
Thanks for your reply..
i have something which i didnt get..

/bin/find /path/tofile -name filename.whatever -size +10485760c > ./big.dat

i have several files (*.txt) under the /var/opt/abc, then also is this command work?

what I'm looking for is, as i said i have serveral files (*.txt) under the /var/opt/abc. if any of the file increased to more than 1mb, then i wanna send a mail with increased file name and size. Thanks once again.
Reply With Quote
  #5  
Old 08-12-2008
Registered User
 

Join Date: Jun 2008
Posts: 95
Yes,
/path/tofile => /var/opt/abc
filename.whatever => "*.txt"
Reply With Quote
  #6  
Old 08-12-2008
Registered User
 

Join Date: Aug 2008
Posts: 22
Thanks for your reply.

I just tried with the script which you give me and it did work with some changes. I modified the script like below

find -name core.* -size +10485760c > ./big.txt
#if [[ -s ./big.txt ]] ; then
#big.txt > /usr/bin/mailx -s 'file too big ' abc@xyz.com

this works but I want to see file size too like this..
-rw------- 1 root root 254517248 Aug 4 21:36 core.2909 and this line i wanna send as a mail.

when I tried with this...

/bin/find /path/tofile -name filename.whatever -size +10485760c > ./big.dat It says couldn't find the /bin/find.

Thanks for your help.
Reply With Quote
  #7  
Old 08-12-2008
vidyadhar85's Avatar
The Tutor
 

Join Date: Jun 2008
Location: INDIA
Posts: 537
try this....

ls -lrt|awk '$5 > 10485760 {print}' > ./big.txt
if [[ -s ./big.txt ]] ; then
/usr/bin/mailx -s 'file too big ' abc@xyz.com < big.txt

Last edited by vidyadhar85; 08-12-2008 at 07:01 PM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0