The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 07: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 10:40 PM
PHP Script that sends mail - Postfix breaks it boopfm523 Shell Programming and Scripting 0 03-05-2008 11:38 PM
How to write a shell script to send an email to an id madhumathikv Shell Programming and Scripting 4 10-23-2007 05:19 PM
Email message if file size > 0 bytes poste_d_ordure Shell Programming and Scripting 1 06-02-2006 07:02 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-12-2008
s_linux s_linux is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 81
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
  #2 (permalink)  
Old 08-12-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,754
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.
  #3 (permalink)  
Old 08-12-2008
s_linux s_linux is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 81
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?
  #4 (permalink)  
Old 08-12-2008
s_linux s_linux is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 81
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.
  #5 (permalink)  
Old 08-12-2008
sudhamacs sudhamacs is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 98
Yes,
/path/tofile => /var/opt/abc
filename.whatever => "*.txt"
  #6 (permalink)  
Old 08-12-2008
s_linux s_linux is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 81
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.
  #7 (permalink)  
Old 08-12-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,391
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 10:01 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0