write the script to get the file size and sends an email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting write the script to get the file size and sends an email
# 1  
Old 08-12-2008
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  
Old 08-12-2008
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  
Old 08-12-2008
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  
Old 08-12-2008
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  
Old 08-12-2008
Yes,
/path/tofile => /var/opt/abc
filename.whatever => "*.txt"
# 6  
Old 08-12-2008
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  
Old 08-12-2008
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 11:01 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

can't write file size more than 1G

running aix 7.1 ... # lsfs -q /admin/sft Name Nodename Mount Pt VFS Size Options Auto Accounting /dev/lv01 -- /admin/sft jfs 41943040 rw yes no (lv size: 41943040, fs size: 41943040, frag size: 4096, nbpi: 4096,... (3 Replies)
Discussion started by: ppchu99
3 Replies

2. Shell Programming and Scripting

how to write script to change email address

we have 4000 html pages that need an email address changed. eg) company@yahoo.com to company@hotmail.com we only want the file modified date to be changed when there has been a change to the file. Should I be using grep? I fairly new to UNIX and was told to using something like... (2 Replies)
Discussion started by: mchelle_99
2 Replies

3. Shell Programming and Scripting

Script to read file size and send email only if size > 0.

Hi Experts, I have a script like $ORACLE_HOME/bin/sqlplus username/password # << ENDSQL set pagesize 0 trim on feedback off verify off echo off newp none timing off set serveroutput on set heading off spool Schemaerrtmp.txt select ' TIMESTAMP COMPUTER NAME ... (5 Replies)
Discussion started by: welldone
5 Replies

4. Shell Programming and Scripting

Script to Alert a file and sends an email

Hello All, I need a script which alerts me when a files arrive in a directory. I don't need every file. but i need some specific pattern file. And i need to get automatic email gettin as an alert For Example: /a/b/c/ : directory format of file should take regualr expression or manually... (2 Replies)
Discussion started by: krux_rap
2 Replies

5. UNIX for Dummies Questions & Answers

BASH script that sends text message or email

Hi, I have a BASH shell script that batch processes data. I often start this script before I leave to go home for the day, and leave it processing over night. It has come to my attention that it would be very useful for me to add the capability of making the script notify me about certain things... (2 Replies)
Discussion started by: msb65
2 Replies

6. Shell Programming and Scripting

Need to write script to send an email for password reset.

Hi all, Please suggest I want to write a scritp which will send a email to my mail address before the time duration of the password reset, Should write mail stating that your password will expire in so and so days"" Rgds:b: Ann. (2 Replies)
Discussion started by: Haque123
2 Replies

7. Shell Programming and Scripting

to write a script to compare the file size in the current directory and previous dir

hi, i am new to this site. i want to write a script to compare the file size of the files in the current dir with the files in the previous directory. the files name will be same, but the filename format will be as xyzddddyymm.txt. the files will arrive with the month end date(i want to... (5 Replies)
Discussion started by: tweety
5 Replies

8. Shell Programming and Scripting

how to know if the mailx command really sends the mail to the email address?

Hi guys, I have a question about the returning message of the mailx command. if I run a mailx command, how can I know if the email has been sent to the email address? If the email address doesn't exist, is there any error message returned? If yes, how can I get the error message? Thanks... (3 Replies)
Discussion started by: sheenshine
3 Replies

9. Shell Programming and Scripting

Running script that sends an html formatted email fails when its run as cronjob

Hi Im very new at working with unix and this problem I simply can not understand. I know there are a lot of threads about problems with shell scripts behaving differently when run from a terminal and from a cronjob. I have tried everything(almost) but I still havent cracked this problem. Im... (15 Replies)
Discussion started by: Nightowl
15 Replies

10. Shell Programming and Scripting

How to write a shell script to send an email to an id

Hi all, I want to know how to send an email using shell script ..... I tried a command call mail but it did not work.. Please any one reply.. With example if you know thanks.. Madhu (4 Replies)
Discussion started by: madhumathikv
4 Replies
Login or Register to Ask a Question